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
| authors = [] | |
| def collect_authors(): | |
| answer = None | |
| while answer != "q": | |
| answer = input("Who is your favorite author?") | |
| authors.append(answer) | |
| print(authors) |
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
| a = 0 | |
| def increment(): | |
| global a | |
| a += 1 |
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
| def increment(a): | |
| return a + 1 |
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
| shapes = [tr1, sq1, cr1] | |
| for a_shape in shapes: | |
| if type(a_shape) == "Triangle": | |
| a_shape.draw_triangle() | |
| if type(a_shape) == "Square": | |
| a_shape.draw_square() | |
| if type(a_shape) == "Circle": | |
| a_shape.draw_circle() |
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
| shapes = [tr1, sw1, cr1] | |
| for a_shape in shapes: | |
| a_shape.draw() |
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 Shape(): | |
| def __init__(self, w, l): | |
| self.width = w | |
| self.len = l | |
| def print_size(self): | |
| print("""{} by {}""".format(self.width, self.len)) | |
| class Square(Shape): | |
| pass |
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, name, breed, owner): | |
| self.name = name | |
| self.breed = breed | |
| self.owner = owner | |
| class Person(): | |
| def __init__(self, name): | |
| self.name = name |
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 Rectangle(): | |
| def __init__(self, w, l): | |
| self.width = w | |
| self.length = l | |
| def print_size(self): | |
| print("""{} by {}""".format(self.width, self.length)) | |
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 Rectangle(): | |
| recs = [] | |
| def __init__(self, w, l): | |
| self.width = w | |
| self.len = l | |
| self.recs.append((self.width, self.len)) | |
| def print_size(self): | |
| print("""{} by {}""".format(self.width, self.len)) |
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 Card: | |
| suits = ["spades", "hearts", "diamonds", "clubs"] | |
| values = [None, None,"2", "3", "4", "5", "6", "7", "8", | |
| "9", "10", "Jack", "Queen", "King", "Ace"] | |
| def __init__(self, v, s): | |
| """suit + value are ints""" | |
| self.value = v | |
| self.suit = s |