samedi 2 octobre 2021

Executing a function in python using if statement [closed]

a function that measures the time needed in a trip

  def time():
    distance = float(input("how many kilometers are you traveling "))
    route = input("are you taking an autoroute? ")
    autoroute1 = distance / 110
    autoroute2 = distance / 90
    if route == "Yes":
     return   autoroute1
    else:
       return autoroute2

a function that measures the price of the trip based on its quality

def price():
    car_quality = ["Basic", "Meduim", "Luxuery"]
    car = input("What is the quality of yur ride ")
    car in car_quality
    Basic = 30
    Meduim = 60
    Luxury = 120
    if car_quality == "Basic":
       bas =  time() * Basic
       return bas
    elif car_quality == "Meduim":
        med = time() * Meduim
        return med
    else:
        lux = time() * Luxury
        return lux

print(price())

Aucun commentaire:

Enregistrer un commentaire