16. Class It Up


#1

Hi
I got it correct by using the clue, but I don’t understand one thing
Here’s my code:

**

class Triangle(object):
  number_of_sides = 3
  def __init__(self, angle1, angle2, angle3):
    self.angle1 = angle1
    self.angle2 = angle2
    self.angle3 = angle3
    
  def check_angles(self):
    if (self.angle1 + self.angle2 + self.angle3) == 180:
      return True
    else:
      return False**

The previous lesson told us to do the following

self.angle1 = angle1
self.angle2 = angle2
self.angle3 = angle3

Then why do we have to write:

`

self.angle1 + self.angle2 + self.angle3?

`

thanks in advance.


#2

To verify that the angles add up to 180 degrees.


#3

I know, but we already defined

self.angle1 = angle1
self.angle2 = angle2
self.angle3 = angle3

so why write it again


#4

That only reads in the inputs and assigns them to instance variables. The values could be any amount. At this stage we know nothing about their sum.


#5

Oh, thanks for helping