Final answer:
The program creates a list of random integers based on user input and displays statistics about the list, such as the lowest number, highest number, sum, and average of the integers.
Step-by-step explanation:
Writing a Program to Generate Random Integers
To write a program that generates a list of random integers based on user input, we can use Python's random module. First, we need a function to create the list of random integers. Then, we can print the required statistics based on the generated list. Below, a simple Python program is outlined which accomplishes this task:
import random
def generate_random_integers(n, min_val=0, max_val=50):
return [random.randint(min_val, max_val) for _ in range(n)]
def main():
num = int(input('Enter the number of random integers you want to generate: '))
random_integers = generate_random_integers(num)
print('A. The list of integers:', random_integers)
print('B. The lowest number in the list:', min(random_integers))
print('C. The highest number in the list:', max(random_integers))
print('D. The total sum of all the numbers in the list:', sum(random_integers))
print('E. The average number in the list:', sum(random_integers)/len(random_integers))
if __name__ == '__main__':
main()
This program first defines a function to generate a list of random integers, and then it executes the main function, which displays the list and the calculated statistics to the user.