Question: Write a program that calculates the total movie ticket price for a group of people, taking into account both their ages and the time of
Write a program that calculates the total movie ticket price for a group of people, taking into account both their ages and the time of the movie.
Requirements:
The program should first ask whether the movie is being watched during the 'day' or 'night'.
It should then ask how many people are watching the movie.
For each person, the program should ask their age and calculate the price based on the following rules:
Toddlers under years old: Free, regardless of the time.
Daytime prices:
$ for anyone aged or above.
Nighttime prices:
$ for ages to $ for ages to $ for ages and above.
The program should calculate and print the total price for all the tickets.
Example Interaction:
Are you watching the movie during the 'day' or 'night'? night
How many people are watching the movie?
Enter the age of person :
Enter the age of person :
Enter the age of person :
The total price for the movie tickets is: $
Notes:
The input for the time of the movie should be either 'day' or 'night'.
The number of people and each age entered should always be a nonnegative integer.
Prices vary based on the time and age, as per the provided rules.
time inputAre you watching the movie during the 'day' or 'night'?
numpeople intinputHow many people are watching the movie?
totalprice
def calculateticketpricetimeofday, age:
if age :
return
elif timeofday 'day':
return
else:
if age :
return
elif age :
return
else:
return
for i in range numpeople :
age intinputfEnter the age of the person i
totalprice calculateticketpricetime age
printfThe total price for the movie tickets is: $totalprice
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
