css-learner
answered Jul 30 '21 00:00
use random module , randint () function is in random module .
syntax
randint(x,y) : where x and y is integer value , and x should be less than y.
return integer value between x and y
import random
print(random.randint(1,100))
so the output of the above code will be any number between 1,100
what will happen if we pass the integer value of the second argument is less than the first argument integer
i mean x>y
import random
print(random.randint(100,1))
it will generate ValueError: empty range for randrange() so it means you cant pass the x>y , it must be first argument is samller integer value than second argument in random.randint()