Skip to content

Commit be0ac76

Browse files
committed
Complete task-3 Classes and objects
1 parent a5f9233 commit be0ac76

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Person:
2+
def __init__(self, name: str, age: int, preferred_operating_system: str):
3+
self.name = name
4+
self.age = age
5+
self.preferred_operating_system = preferred_operating_system
6+
7+
imran = Person("Imran", 22, "Ubuntu")
8+
print(imran.name)
9+
#print(imran.address)
10+
#error: Person class has no attribute "address"
11+
12+
eliza = Person("Eliza", 34, "Arch Linux")
13+
print(eliza.name)
14+
#print(eliza.address)
15+
#the same error: Person class has no attribute "address"
16+
17+
def is_adult(person: Person) -> bool:
18+
return person.age >= 18
19+
20+
print(is_adult(imran))
21+
22+
def get_phone(person: Person) -> str:
23+
return person.phone_number
24+
# After running mypy this method also causes an error, because Person class has no attribute "phone_number"

0 commit comments

Comments
 (0)