Skip to content

Commit 15c8973

Browse files
authored
Create age.py
1 parent 5b5a4c5 commit 15c8973

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

age.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#Write a program that prompts the user to enter a series of age (number) to be inserted in a list named age.
2+
The size of the list is 10. The program then, will evaluate the status ofchildoradultbased on the user input.
3+
If the age is less than or equal to 18, the program will store it in the children list.
4+
However, if the age is greater than 19, the program will store it in the adult list.
5+
The program has to display the content of the three lists.
6+
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.
7+
8+
9+
-
10+
11+
total = 0
12+
age = []
13+
14+
a = (input('Enter age: '))
15+
16+
while a != '':
17+
age.append(int(a))
18+
a = input()
19+
20+
21+
for i in age:
22+
if i <= 0:
23+
print('This age is not defined')
24+
elif i in range(1, 18):
25+
print('Children')
26+
27+
elif i >= 19:
28+
print('Adult')
29+
30+
31+
32+
print(' ')
33+
print('List of number you just input is', age)
34+
35+
print(' ')
36+
Sum = sum(age)
37+
print('The total sum of numbers in this list are', Sum)
38+
39+
print(' ')
40+
print('There are', len(age), 'elements in the input')

0 commit comments

Comments
 (0)