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
  Regular expression: return string, not list Pavel_47 3 2,452 Jan-14-2021, 11:49 AM
Last Post: Pavel_47
  Getting Shell to take prompt string plus int value and carriage return bayouprophet 1 1,729 Aug-29-2020, 05:13 PM
Last Post: bowlofred
  Winsorized Mean and Standard Deviation Wheeliam 0 1,793 Jul-11-2020, 05:27 PM
Last Post: Wheeliam
  return string from function with one argument jamie_01 2 2,148 May-28-2020, 11:07 PM
Last Post: menator01
  standard library modules chpyel 4 2,762 May-10-2020, 02:58 PM
Last Post: snippsat
  output while using return instead of print muza 2 2,093 Apr-23-2020, 09:38 AM
Last Post: muza
  How to assign this output to a string variable? Pedroski55 3 2,589 Apr-18-2019, 07:23 AM
Last Post: Yoriz
  Is there a standard for autocommit In PEP 249 zatlas1 10 5,106 Feb-06-2019, 04:56 PM
Last Post: buran
  Graphics and standard deviation rocioaraneda 3 2,673 Jan-09-2019, 10:53 PM
Last Post: micseydel
  Pass variable script return twice output problem Faruk 8 4,295 Dec-26-2018, 11:57 AM
Last Post: Faruk

Forum Jump:

User Panel Messages

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