Python Forum
Calculate and print the total cost - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Calculate and print the total cost (/thread-15037.html)



Calculate and print the total cost - isha_dx - Dec-31-2018

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


RE: help - metulburr - Dec-31-2018

is this homework?


RE: Calculate and print the total cost - isha_dx - Jan-01-2019

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.


RE: Calculate and print the total cost - Mr_W - Jan-01-2019

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!




RE: Calculate and print the total cost - Gribouillis - Jan-01-2019

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.


RE: Calculate and print the total cost - isha_dx - Jan-02-2019

thanks for your help


RE: Calculate and print the total cost - vncdzg - Feb-09-2021

hi i also have been given this question and i really need help could you tell me how you done it


RE: Calculate and print the total cost - nilamo - Feb-10-2021

Share your code. The above discussion should be enough to help you get started.