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

Recommended Answers

All 2 Replies

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.

IMHO speaking of speed as an integer is nonsence.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.