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 4 years old): Free, regardless of the time.
Daytime prices:
$8 for anyone aged 4 or above.
Nighttime prices:
$12 for ages 4 to 16, $15 for ages 17 to 54, $13 for ages 55 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? 3
Enter the age of person 1: 3
Enter the age of person 2: 16
Enter the age of person 3: 45
The total price for the movie tickets is: $27
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 non-negative integer.
Prices vary based on the time and age, as per the provided rules.
time = input("Are you watching the movie during the 'day' or 'night'? ")
num_people = int(input("How many people are watching the movie? "))
total_price =0
def calculate_ticket_price(time_of_day, age):
if 0< age <4:
return 0
elif time_of_day == 'day':
return 8
else:
if 4<= age <=16:
return 12
elif 17<= age <=54:
return 15
else:
return 13
for i in range (1, num_people +1):
age= int(input(f'Enter the age of the person {i}'))
total_price += calculate_ticket_price(time, age)
print(f"The total price for the movie tickets is: ${total_price}")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!