Created
March 2, 2017 17:50
-
-
Save calthoff/8ad5ae800f2ed4d17ea906861ce9a599 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This program is chapter 14 challenge one: | |
class Shape(): | |
def __init__(self, shape): | |
self.shape = shape | |
def what_am_i(self): | |
print("I am a {}".format(self.shape)) | |
class Square(Shape): | |
def what_am_i(self): | |
super(Square, self).what_am_i() # super is for multi-inheritance | |
class Rectangle(Shape): | |
def what_am_i(self): | |
super(Rectangle, self).what_am_i() | |
# Create some objects: | |
square = Square("square") | |
rectangle = Rectangle("rectangle") | |
square.what_am_i() | |
rectangle.what_am_i() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment