This code is to check about the whether the person is eligible to ride on a roller coaster.
Below are the conditions:
- His height has to be higher than or equal to 120 cm. If not, he cant ride.
- If his height is lesser than 120 cm, below are the price that applies to him:
- His height has to be higher than or equal to 120 cm. If not, he cant ride.
- If his height is lesser than 120 cm, below are the price that applies to him:
- if age is less than 12, ticket price is 25 rupees
- if age is between 12 and 18, ticket price is 40 rupees.
- if age is higher than 18, ticket price is 50 rupees.
- A special offer is given for Youngsters whose age is between 25 and 28. Ticket price is completely free.
- Additionally photo copy is also available. For each copy additional 30 rupees will be added. This applies to all age persons.
Below is the code that helps you with the above scenario:
#Price for Roller-coaster
print("Welcome to PGRSpot Roller Coaster")
height = float(input("Enter your height in cm:\n"))
# age = int(input("Enter your age:\n"))
if height >= 120:
print("You are eligeble to ride the Roller coaster")
age = int(input("Enter your age:\n"))
if age <= 12:
price = 25
print("Child ticket is ₹25")
elif age < 18:
price = 40
print("Youth ticket is ₹40")
elif age >= 25 and age <= 28:
price = 0
print(f'Special Offer, you can ride ₹{price}')
elif age >= 18:
price = 50
print("Adult ticket is ₹50")
photo = input(
"Do you need the photocopy, Enter 'Y' or 'N'(Additional ₹30 need to be paid):\n"
)
lower_photo = photo.lower()
if lower_photo == "y":
total_price = price + 30
else:
total_price = price
print(f'Your total price is ₹{total_price}')
else:
print("You need to grow to continue in Roller-coaster")
Post a Comment
Post a Comment