Skip to content

Commit a4b84ee

Browse files
Boshra MahmoudiBoshra Mahmoudi
authored andcommitted
exercise2: Classes and objects
1 parent 61dafbb commit a4b84ee

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎sprint5/Exercise2.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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.age)
10+
print(imran.preferred_operating_system)
11+
12+
13+
eliza = Person("Eliza", 34, "Arch Linux")
14+
print(eliza.name)
15+
16+
def is_adult(person: Person) -> bool:
17+
return person.age >= 18
18+
19+
print(is_adult(imran))
20+
21+
def get_address(person: Person) -> str: #this returns an error
22+
return person.address

0 commit comments

Comments
 (0)