Answer to Question #301971 in Python for Kate

Question #301971

Create a program that displays the fare based on the entered destination. The starting station is Araneta-Cubao Use the code destination to shorten the user's input



1
Expert's answer
2022-02-26T11:32:39-0500
'''
    Create a program that displays the fare based on the entered destination.
    The starting station is Araneta-Cubao Use the code destination to shorten
    the user's input.
'''
Destinations = [1,2,3,4,5,6,7,8,9,10]
Dist         = [10,20,30,40,50,60,70,80,90,100]
UnitFare = 5


d=0
while(d<1 or d>max(Destinations)):
    s = "Enter destination code from 1 to "+str(max(Destinations))+"): "
    d = int(input(s))
    for r in range(0,len(Destinations)):
        if(d==Destinations[r]): k = r


Fare = UnitFare*Dist[k]
print("Unit Fare = ",UnitFare," per Km.")
print("Distance of destination-",d,"from Araneta-Cubao:",Dist[k],"Kms.")
print("Total Fare = ",Fare)

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