Last active
March 13, 2020 09:57
-
-
Save dfbarrero/9b30c749986885373c8c250b3901ec9d to your computer and use it in GitHub Desktop.
Python OOP naive example.
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 Dog: | |
| def __init__(self): | |
| self.name = "Unknown" | |
| self.age = 10 | |
| def bit(self): | |
| print(self.name + " has bitten") | |
| def describe(self): | |
| print("Name: ", self.name) | |
| print("Age: ", self.age) | |
| if __name__ == '__main__': | |
| snoopy = Dog() | |
| laika = Dog() | |
| snoopy.name = "Snoopy" | |
| snoopy.age = 4 | |
| laika.name = "Laika" | |
| snoopy.bit() | |
| snoopy.describe() | |
| print() | |
| laika.describe() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment