Python Forum

Full Version: How to return a standard output instead of string
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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?