ModdersCentral

Full Version: Python Taxi Fare
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
taxi fare calculator based on the user given distance.
It costs £2.20 to start with, for every miles up to 10 its £0.70 and over 10 miles it changes to a discounted £0.30 per mile.
Code:
distance = input("journey in  miles?")
basefair = 2.20 #starting meter
under10milefair = 0.7
over10milefair = 0.30
if distance <=10:
    print ("price will be" , (distance * under10milefair)+basefair)
elif distance >10:
    the10miles = (10 * under10milefair)+basefair
    print ("price will be" , ((float(distance) - 10.0) *  over10milefair) + the10miles)
www.000webhost.com