Question: Write Python code for this problem The Python random module has functions that can be used to generate random numbers For example the randint function

The Python random module has functions that can be used to generate

Write Python code for this problem

The Python random module has functions that can be used to generate random numbers For example the randint function can be used to generate random integers within a specified range, e.g. 1 import random 2 a_randint random.randint (1, 10) 3 print (a_randint) = will generate a random integer, a_randint, within the range [1,10]. If you run the code repeat- edly, using a for loop, you can generate as many numbers as you want. Your task is to, a) Use randint to generate a list of 100 random integers between 1 and 10. b) Write the integers to a text file. c) Open the file, read the integers into an array (i.e. a list). d) Print the average of the integers. Note: use intrinsic functions to compute the average. Hint: what is the definition of average?

Step by Step Solution

3.44 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import random file opennumberstxtw for x in range100 n randomrandint110 filewritestrn fileclose f... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!