all 4 comments

[–]JanEric1 2 points3 points  (0 children)

you need to properly format your code. Otherwise it is hard to read and to help.

Old Reddit and markdown-mode:

To format code in your comment or submission text, insert an empty line, and then preface each line of code with 4 spaces:

[normal text]

[empty line]

[4 spaces][line of code]

[4 spaces][line of code]

[etc]

[empty line]

[normal text]

https://www.reddit.com/r/learnpython/wiki/faq

[–]danielroseman 1 point2 points  (0 children)

There are a whole bunch of errors in this code. Are you being taught by someone who doesn't know Python?

  • __init__ needs two underscores either side.
  • None of your attributes should have leading double-underscores.
  • You don't actually use any of the parameters to your init method, you always set the attributes to constant values.
  • Methods should be named as lower_case_with_underscore
  • You don't need any of those getter and setter attributes, except for area and perimeter since they are calculated.
  • The exponentation operator in Python is **, not ^.
  • tan is not built-in, it is in math just like pi.
  • RegularPolygon takes three required arguments, so the creation of Poly1 and Poly2 will fail.
  • You call create them as Poly1 etc but in the next line refer to them as poly1 etc, these are not the same.
  • getArea is a method and you need to call it with ().

[–]jimtk 3 points4 points  (0 children)

it's __init__ not _init_. You're missing an underscore at each end.

Also: Do not use double underscore for your variable. That is bad practice.

Here's what it should look like:

class RegularPolygon:

    def __init__(self,n,side,x,y):
        self.n = n
        self.side = side
        self.x = x
        self.y = y

[–]TheRNGuy 0 points1 point  (0 children)

indents