-
Notifications
You must be signed in to change notification settings - Fork 1
/
zoo_ticket.py
28 lines (26 loc) · 1.07 KB
/
zoo_ticket.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
#A particular zoo determines the price of admission based on the age of the guest. Guests 2 years of age and less are admitted without charge. Children between 3 and 12 years of
#age cost RM14.00. Seniors aged 65 years and over cost RM18.00. Admission for all other guests is RM23.00. Create a program that begins by reading the ages of all of the guests
#in a group from the user, with one age entered on each line. The user will enter a blank line to indicate that there are no more guests in the group. Then your program should
#display the admission cost for the group with an appropriate message. The cost should be displayed using two decimal places.
age=[]
cost=0
print('Press "Enter" to add new ages')
print('After finish enter the ages, press "Enter" button twice')
print('Enter the ages of members:')
l=(input())
while l != '':
age.append(int(l))
l=input()
for i in age:
if i<=2:
cost=cost+0
elif i>=3 and i<=12:
cost=cost+14
elif i>=65:
cost=cost+18
else:
cost=cost+23
if cost==0:
print('Enter a valid input!!!')
else:
print('Total cost of admission = $ %.2f'%(cost))