mardi 27 août 2019

Is there a way to clearly define a random number as a variable to use it in a function?

I cant clearly use a random int as a variable to use it for a comparison in my code. It seems to only throw out the first if statement no matter the random number produced.

from random import randint
rate = randint(0, 255)
wind = rate
print(rate)
if wind > 251:
    print("The hurricane is a category 5!")
elif wind <= 251 or wind >= 209:
    print("The hurricane is a category 4!")
elif wind <= 208 or wind >= 178:
    print("The hurricane is a category 3!")

The code is suppose to use the random number in a range to determine a rating of hurricane and print the message regarding. code works to certain extent.. no error message just always prints category 4 line no matter the random number the script produces




Aucun commentaire:

Enregistrer un commentaire