-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathage.py
More file actions
35 lines (27 loc) · 870 Bytes
/
age.py
File metadata and controls
35 lines (27 loc) · 870 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
"""age program
Program for defining ages
"""
gulls = int(input("Сколько чаек?: "))
def fmtnum(num, str1, strS, strM):
"""format number with trailing word
Format number and trailing words according to number
"""
if 11 <= num%100 <= 14:
return strM % num
if num%10 == 1:
return str1 % num
elif 2 <= num%10 <= 4:
return strS % num
else:
return strM % num
age = int(input("Ваш возраст?: "))
print("На острове %s." % fmtnum(gulls, "%d чайка", "%d чайки", "%d чаек"))
print("— Вам %s, " % fmtnum(age, "%d год", "%d года", "%d лет"), end="")
if age <= 2:
print("пора в ясли!")
elif 3 <= age <= 6:
print("пора в садик!")
elif 7 <= age <= 16:
print("пора в школу!")
else:
print("даже не знаю...")