Write a Python program to help a child plan their visit to an amusement park.
Ask for the child’s name and store it in a variable called name.
Ask how much money they brought with them and store it in a variable called money_brought (as an integer).
Tickets to enter the park cost $20, and each ride costs $5.
Subtract the ticket cost from their total money:
remaining_money = money_brought - 20
Ask how many rides they want to go on and store it in a variable called rides (as an integer).
Multiply rides * 5 and store it in a variable called ride_cost.
Subtract the ride_cost from remaining_money to find out what’s left.
Use if-else to check:
If ride_cost is less than or equal to remaining_money, print:
“Great choice, [name]! You can enjoy [rides] rides and will have $[remaining_money – ride_cost] left!”
If ride_cost is more than remaining_money, print:
“Oops, [name]! You need $[ride_cost – remaining_money] more to go on [rides] rides. Try fewer rides!”
We’re always looking for international STEM educators to join our team. If you are interested, please send us a mail and we’ll get back to you!
If you have any questions, kindly send us a mail. Don’t forget to follow and like all our social accounts to get updates on competitions!
