-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_oop_class.py
More file actions
40 lines (33 loc) · 1.02 KB
/
Copy pathpython_oop_class.py
File metadata and controls
40 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class Person:
def __init__(self, first, last):
self.firstname = first
self.lastname = last
def __eq__(self, other):
return (self.firstname == other.firstname) \
and (self.lastname == other.lastname)
class Student(Person):
def __init__(self, first, last, school, id):
super().__init__(first, last)
self.school = school
self.id = id
man1 = Person('Homer', 'Simpson')
man2 = Person('Homer', 'Simpson')
woman = Person('Marge', 'Simpson')
student = Student('Marge', 'Simpson', 'Simmons', 2468)
print(man1 == man1)
print(man1 == man2)
print(man1 == woman)
print(woman == student)
print(student == woman)
print("Coding has the following benefits: ")
pros_iter = iter(["Computational Thinking Skills",
"Mathematics Skills",
"Logical Thinking Skills",
"Problem Solving Skills",
"..."])
while True:
try:
benefit = next(pros_iter)
except StopIteration:
break
print(benefit)