how do i make a code that willfind the distance wether or not your speed is a float or an integer. please help i get no assistance in my class as techer is awful
how do i make a code that willfind the distance wether or not your speed is a float or an integer. please help i get no assistance in my class as techer is awful
The trick is often to convert the number to a float
>>> ispeed = 1 # <--- integer speed
>>> fspeed = 0.5 # <--- float speed
>>> sspeed = "0.8" # <--- string speed
>>> ispeed = float(ispeed)
>>> fspeed = float(fspeed)
>>> sspeed = float(sspeed)
>>> print(ispeed, fspeed, sspeed)
1.0 0.5 0.8
After applying float()
, all the speeds are floating numbers.