Python Forum

Full Version: Calculate and print the total cost
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Please help, i'm stuck.


Write Python code to allow a user to enter the number of bus tickets required. The user is then asked to enter the price of a bus ticket. Calculate and print the total cost. Ask the user to enter the amount of money offered, calculate and print the change, in the format
Change from £nn.nn is £mm.nn
is this homework?
no it’s a question i got given to push my python knowledge further from a friend who is helping my learn python, but i can’t seem to do it. and the friend who gave it to me hasn’t replied with some help so i thought i’d ask here.
By just giving you the code the learning aspect would be pretty much gone so the total code is in the spoiler. I'll give you some hints now so you can give it a try yourself first.
Hints:
-You have to prompt the user for the number of tickets, the price and the amount of money they give you. Use input() to prompt the user.
-After prompting the number of tickets and the price you can just calculate the total price and prompt again for the money given. Then calculate again and print it.

If you have any questions or comments don't hesitate to message
W

ps. Don't give up! I started learning python like 1.5 weeks ago and however the start is hard you'll get the hang of it fast!

Start with this
Quote:Write Python code to allow a user to enter the number of bus tickets required.
You can use a tutorial such as this one.
thanks for your help
hi i also have been given this question and i really need help could you tell me how you done it
Share your code. The above discussion should be enough to help you get started.