Python Forum
How to return a standard output instead of string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to return a standard output instead of string
#1
I'm writing a code for return the formula of a circle by giving the coordinates of the O and the radius
this is a part of my code
class circle:
    
    def __init__(self,o_x,o_y,r):
        if(r<0):
            raise ArithmeticError("Radious can't be smaller than 0")
        self.o_x=float(o_x)
        self.o_y=float(o_y)
        self.r=float(r)
        self.co_x=-2*self.o_x
        self.co_y=-2*self.o_y
        self.c=(self.o_x)**2+(self.o_y)**2-self.r**2

    def func(self):
        concat_x="+"
        concat_y="+"
        concat_c="+"
        if(self.co_x<0):
            concat_x=""
        if(self.co_y<0):
            concat_y=""
        if(self.c<0):
            concat_c=""
        func="x**2 " + concat_x + str(self.co_x) + "x " + "+y**2 " + concat_y + str(self.co_y) + "y " + concat_c + str(self.c)+" = 0"
        return func


the func()return the formula of the circle.But it return output as a String with (' ')quotes just like
Output:
'x**2 + 4x + y**2 +6y -15'
But I need to return a Standard Output without (' ') just like
Output:
x**2 + 4x + y**2 +6y -15
Reply
#2
What to mean by "standard output"? In Python, the standard output (sys.stdout) is a file stream that (normally) displays text to the user. That's where the print function sends things. If you print the string, you won't see the quotes. Is that all you want?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Return a string or byte object from Enum class? Calab 5 1,959 May-14-2025, 05:21 PM
Last Post: snippsat
  Regular expression: return string, not list Pavel_47 3 4,102 Jan-14-2021, 11:49 AM
Last Post: Pavel_47
  Getting Shell to take prompt string plus int value and carriage return bayouprophet 1 2,920 Aug-29-2020, 05:13 PM
Last Post: bowlofred
  Winsorized Mean and Standard Deviation Wheeliam 0 2,836 Jul-11-2020, 05:27 PM
Last Post: Wheeliam
  return string from function with one argument jamie_01 2 3,523 May-28-2020, 11:07 PM
Last Post: menator01
  standard library modules chpyel 4 4,663 May-10-2020, 02:58 PM
Last Post: snippsat
  output while using return instead of print muza 2 3,271 Apr-23-2020, 09:38 AM
Last Post: muza
  How to assign this output to a string variable? Pedroski55 3 4,142 Apr-18-2019, 07:23 AM
Last Post: Yoriz
  Is there a standard for autocommit In PEP 249 zatlas1 10 9,111 Feb-06-2019, 04:56 PM
Last Post: buran
  Graphics and standard deviation rocioaraneda 3 4,557 Jan-09-2019, 10:53 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020