Skip to content

Commit 79d0a12

Browse files
author
Fatma Degirmenci
committed
Update the is_adult method
1 parent 864e986 commit 79d0a12

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

sprint5/methods.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from datetime import date
2+
3+
4+
class Person:
5+
def __init__(self, name: str, date_of_birth: date, preferred_operating_system: str):
6+
self.name = name
7+
self.date_of_birth = date_of_birth
8+
self.preferred_operating_system = preferred_operating_system
9+
10+
def is_adult(self) -> bool:
11+
today=date.today()
12+
age=today.year -self.date_of_birth.year
13+
14+
if(today.month,today.day)<(self.date_of_birth.month,self.date_of_birth.day):
15+
age-=1
16+
return age>=18
17+
18+
imran = Person("Imran", date(2001,9,16), "Ubuntu")
19+
print(imran.is_adult())

0 commit comments

Comments
 (0)