Skip to Content
Introduction to Classes

Finally, let’s create an Equilateral class that inherits from our Triangle class. (An equilateral triangle is a triangle whose angles are all 60˚, which also means that its three sides are equal in length.)



Create a class named Equilateral that inherits from Triangle.

Inside Equilateral, create a member variable named angle and set it equal to 60.

Create an __init__() function with only the parameter self, and set self.angle1, self.angle2, and self.angle3 equal to self.angle (since an equilateral triangle’s angles will always be 60˚).

Folder Icon

Take this course for free

Already have an account?