-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise1.py
More file actions
36 lines (22 loc) · 767 Bytes
/
exercise1.py
File metadata and controls
36 lines (22 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
1) Define two variables – one to save user's name and one to save user's age
2) Create 2 functions with each to get name and age from the command prompt
3) Create a function which prints the name and age
4) Create a function which calculates and returns the number of decades
the user already lived (e.g. 34 = 3 decades)
"""
name = ''
age = 0
def get_name():
return input('Your name: ')
def get_age():
return int(input('Your age: '))
def print_user_info(name, age):
print('Name: ' + name + '\nAge: ' + str(age))
def decades_lived(age):
return age // 10
name = get_name()
age = get_age()
decades = decades_lived(age)
print_user_info(name=name, age=age)
print('Decades Lived: ' + str(decades))