Write a statement that generates a random number in the range of 1 through 100 and assigns it to a variable named rand.
The following statement that generates a random number in the range of 1 through 100 and assigns it to a variable named rand is as follows:
import random
rand = random.randint(1, 100)
Explanation:
random
module, which provides functions for generating random numbers.andom.randint(1, 100)' is used
to generate a random integer in the range of 1 through 100 and value stored in the variable name 'rand'.