Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 19113

Checking whether a floating-point value is in a range unexpectedly false in Python [duplicate]

$
0
0

I want to write a program that reads speed (real number) entered by the user and prints speed information.For speed over 10 and up to 50 (inclusive) print "average", need to work with float numbers.for example input 49.5and the expected output need to be "average"

I tried with this:

speed = float(input())if speed in range(10,50): print('average')

but doesn't give the expected result, doesn't print 'average'.

49.5

Process finished with exit code 0


Viewing all articles
Browse latest Browse all 19113

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>