Answer to Question #178331 in Python for tas

Question #178331

Write a function that calculates a taxi fare for the travelers. Your program should get the information of the distance traveled by the customer and calculate the taxi fare and should display it to the passenger for the payment to be received. The taxi fare consists of a base fare of RM 4.00 plus charges of RM 0.25 for every 140 meters traveled. Define and call the function accordingly.


1
Expert's answer
2021-04-08T07:35:24-0400


#The start point of the program
def main():
    #Get the information of the distance traveled by the customer 
    distanceTraveled=int(input("The distance traveled by the customer (in KM): "))
    #calculate the taxi fare
    taxiFare=calculateTaxiFare(distanceTraveled)
    #display it to the passenger for the payment to be received.
    print(f"The taxi fare is: ${taxiFare}")
#This function allows to calculate the taxi fare
def calculateTaxiFare(distanceTraveled):
    #The taxi fare consists of a base fare of RM 4.00
    #plus charges of RM 0.25 for every 140 meters traveled.
    return 4.00+(((distanceTraveled*1000)//140)*0.25)




main()

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