Answer to Question #322496 in Python for Jolens

Question #322496

A .Using Python programming language, create a program that allows the user to compute for his/her fare using the information below;







0-5km = P20.00






6-10km = P30.00






11-15km = P40.00








The bus only travels within the province, so the distance does not exceed from 15 kilometers. Your program should ask the user for distance travelled, and your program will compute and display the fare.








Use the If, elif, else statement on your program. Select appropriate data type and create appropriate variable names for your program.











1
Expert's answer
2022-04-02T09:59:44-0400
dist = float(input('Enter a tavel distance (km): '))


if dist <= 5:
    fare = 2
elif dist <= 10:
    fare = 30
else:
    fare = 40


print(f'Your fare is P{fare:.2f}')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS