Skip to content

Commit 801b1c3

Browse files
committed
add types to prep2 & change class property and method
1 parent 22e6770 commit 801b1c3

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

sprint5-prep/prep2-exercise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def open_account(balances, name, amount):
1+
def open_account(balances: dict[str,int], name : str, amount:int):
22
balances[name] = amount
33

44
def sum_balances(accounts):

sprint5-prep/prep4-exercise.py

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

0 commit comments

Comments
 (0)