149k views
3 votes
Write a statement that generates a random number in the range of 1 through 100 and assigns it to a variable named rand.

1 Answer

5 votes

Answer:

rand = random.randint(1,100)

Step-by-step explanation:

The programming language is not stated.

However, I'll answer using Python:

To generate a random integer with an interval, you make use of the followinf syntax.

random.randint(begin,end)

Where begin to end represents the range;

In this case:

begin = 1

end = 100

So, statement becomes

random.randint(1,100)

However, it must be assigned to a variable

So:

rand = random.randint(1,100)

User Carson Holzheimer
by
4.7k points