Question: One can generate a random integer using the random module as follows: i import random random.randint (1 ,10) 2 n Here, we are importing random

One can generate a random integer using the random module as follows: i import random random.randint (1 ,10) 2 n Here, we are importing random and using the randint() function to generate random number between 1 and 10. You will use that information in what follows. First, you will create a while loop that loops indefinitely. To do so start the loop like this: i while True : Now, in each iteration you will generate a random integer n e [1, 10] as described above. Add the integers using an accumulator variable, call it accum. Also, store each n in a list called rand_list. Since you are in an infinite loop you will have to break from it. Add a condition to break from the loop when accum >= 1000. After the loop you will (1) print the value of accum and (2) print the sum of all the integer values in rand list, call it sum_list (Hint: apply the sum() function to the list). Note that accum and sum_list must be equal
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
