-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathage.py
40 lines (27 loc) · 1.03 KB
/
age.py
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
37
38
39
40
#Write a program that prompts the user to enter a series of age (number) to be inserted in a list named age.
#The size of the list is 10. The program then, will evaluate the status of ‘child’ or ‘adult’ based on the user input.
#If the age is less than or equal to 18, the program will store it in the children list.
#However, if the age is greater than 19, the program will store it in the adult list.
#The program has to display the content of the three lists.
#The program also has to calculate and display the total number of elements in all of the lists. Name the Python file as age.py.
-
total = 0
age = []
a = (input('Enter age: '))
while a != '':
age.append(int(a))
a = input()
for i in age:
if i <= 0:
print('This age is not defined')
elif i in range(1, 18):
print('Children')
elif i >= 19:
print('Adult')
print(' ')
print('List of number you just input is', age)
print(' ')
Sum = sum(age)
print('The total sum of numbers in this list are', Sum)
print(' ')
print('There are', len(age), 'elements in the input')