Skip to content

Commit c1e34e4

Browse files
committed
class and Objs
1 parent 407b010 commit c1e34e4

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

.DS_Store

6 KB
Binary file not shown.

type/person.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class Person:
2+
def __init__(self, name: str, age: int, address: str, preferred_operating_system: str):
3+
self.name = name
4+
self.age = age
5+
self.address =address
6+
self.preferred_operating_system = preferred_operating_system
7+
8+
def is_adult(person: Person) -> bool:
9+
return person.age >= 18
10+
11+
# def get_phone(person: Person) -> str:
12+
# return person.phone_number
13+
14+
imran = Person("Imran", 22,"Shiraz", "Ubuntu")
15+
print(imran.name)
16+
print(imran.address)
17+
18+
aida = Person("Aida", 34, "Tehran", "Arch Linux")
19+
print(aida.name)
20+
print(aida.address)
21+
print(is_adult(imran))
22+
23+
24+
25+
26+
# def get_phone(person: Person) -> str:
27+
# return person.phone_number
28+
#
29+
# print(get_phone(aida))
30+
# Person.py:12: error: "Person" has no attribute "phone_number" [attr-defined]
31+
# Found 1 error in 1 file (checked 1 source file)

0 commit comments

Comments
 (0)