Python Forum
New beginner, defining point help :(
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New beginner, defining point help :(
#1
I'M USING PYTHON 3.2.1
================
So I have bought a book few days ago and got to it today. Its called "More Python Programming for the absolute beginner by Jonathan S. Harbour. I have copied the code to see how it works. On the way I experience few annoying errors I can't find a way to solve. Help would be nice  Big Grin

class Point():
    x = 0.0
    y = 0.0

    def _init_(self,x,y):
        self.x = x
        self.y = y
        print("Point constructor")

        def ToString(self):
            return "{X:" + str(self.x) + ",Y:" + str(self.y) + "}"

    class Circle(Point):
        radius = 0.0

        def _init_(self,x,y,radius):
            super()._init_(x,y)
            self.radius = radius
            print("Circle constructor")

            def ToString(self):
                    return super().ToString() + \
                           ",{RADIUS=" + str(self.radius) + "}"

            p = Point(10,20)
            print(p.ToString())

            c = Circle(100,100,50)
            print(c.ToString())
ERROR:

line 1, in <module>

    class Point():

========================

line 13, in Point

    class Circle(Point):
Reply


Messages In This Thread
New beginner, defining point help :( - by Armandas - Apr-24-2017, 09:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  connecting the first point to the last point Matplotlib omar_mohsen 0 4,640 Jan-15-2020, 01:23 PM
Last Post: omar_mohsen

Forum Jump:

User Panel Messages

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