Created
May 6, 2019 08:43
-
-
Save matmunn/ae5012df71d97203ca4c91e6c685dc59 to your computer and use it in GitHub Desktop.
Python demo
This file contains hidden or 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
class Person: | |
def __init__(self, name, age): | |
self.name = name | |
self.age = age | |
def say_hello(self): | |
"""Say hello to the user.""" | |
print(f"Hello, {self.name}.") | |
class Man(Person): | |
gender = 'male' | |
class Woman(Person): | |
gender = 'female' | |
mat = Man('Mat', 28) | |
caitlin = Woman('Caitlin', 27) | |
print("Caitlin is a {}".format(caitlin.gender)) | |
print("Mat is a {}".format(mat.gender)) | |
mat.say_hello() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment