-1

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.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
DanielTQ
  • 9
  • 1
  • you're putting your variables into quotations (making a string of the variable name). Try `tiempo = (cuidad1/MPH)`. Some other things to note... some variables are starting with capital letters, you're not actually printing your output, 2 of your variables are redundant. – Ironkey May 10 '22 at 17:18
  • 3
    I think this is at least part of your problem: [How can I read inputs as numbers?](https://stackoverflow.com/q/20449427/10077) – Fred Larson May 10 '22 at 17:18
  • I removed your Python2 tag since the question is not specific, **but** you should definitely be using Python3 – OneCricketeer May 10 '22 at 17:22
  • @OneCricketeer: Actually, if it is Python 2, my comment is not exactly correct. It would still be better to use something like `float(raw_input())`, though, in that case. – Fred Larson May 10 '22 at 17:27

2 Answers2

0

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}")
elbashmubarmeg
  • 330
  • 1
  • 9
0

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
Sean
  • 524
  • 2
  • 7