i try to get some distance but i cant find the correct form to do tha. i would like some help form the experts.
distance = input()
speed = input()
tiempo = ( distance / speed )
print("Time: ")
have 2 variables "distance & speed" i cant find the correct form to make a division on it. thats the first probem. the 2nd its for these variables i have an other variable defined for each. i try to get the info on 1 variable then put this info in other variable. hmm its hard to explain.
ciudad1 = input()
MPH = input()
distancia = "ciudad1"
velocidad = "MPH"
tiempo = ("ciudad1" / "MPH")
print(Fore.WHITE "time: ")
i try to do that but i need some help.
CodePudding user response:
You need to convert the output of your input
function to the correct format (float
).
distance = float(input())
speed = float(input())
tiempo = distance / speed
print(f"Time: {tiempo}")
CodePudding user response:
You're input is of type <str>
(string). You need to cast it to a numerical type such as float.
distance = float(input())
speed = float(input())
time = distance / speed