-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpt_output.txt
24 lines (22 loc) · 762 Bytes
/
gpt_output.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class User:
def __init__(self, full_name, birthday):
self.name = full_name
self.birthday = birthday # yyyymmdd
name_pieces = full_name.split()
self.first_name = name_pieces[0]
self.last_name = name_pieces[-1]
def age_in_years(self):
today = datetime.date(2001, 5, 12)
yyyy = int(self.birthday[:4])
mm = int(self.birthday[4:6])
dd = int(self.birthday[6:8])
dob = datetime.date(yyyy, mm, dd) # Date of birth
age_in_days = (today - dob).days
age_in_years = age_in_days // 365
return int(age_in_years)
user = User("Dave Bowman", "19710315")
print(user.name)
print(user.first_name)
print(user.last_name)
print(user.birthday)
print(user.age_in_years())