Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in a list and then display the following data: • The lowest number in the list • The highest number in the list • The total of the numbers in the list • The average of the numbers in the list

Respuesta :

Limosa

Answer:

The following are the program in the Python Programming Language.

#declare the list  

lst=[]

#set the for loop  

for num in range(1,21):

 #get the element of the list from the user

 n=int(input('Enter the {} element :' .format(num)))

 #add elements in the list

 lst.append(n)

print()

#print the minimum number in list

print('The lowest number in the list: ',min(lst))

#print the maximum number in list

print('The highest number in the list: ',max(lst))

#print the total of the list

print('The total of the numbers in the list: ',sum(lst))

#print the average of the list

print('The average of the numbers in the list: ',sum(lst)/len(lst))

Output:

Enter the 1 element :53

Enter the 2 element :65

Enter the 3 element :41

Enter the 4 element :23

Enter the 5 element :21

Enter the 6 element :12

Enter the 7 element :96

Enter the 8 element :85

Enter the 9 element :74

Enter the 10 element :98

Enter the 11 element :75

Enter the 12 element :41

Enter the 13 element :54

Enter the 14 element :56

Enter the 15 element :36

Enter the 16 element :25

Enter the 17 element :14

Enter the 18 element :12

Enter the 19 element :45

Enter the 20 element :65

The lowest number in the list:  12

The highest number in the list:  98

The total of the numbers in the list:  991

The average of the numbers in the list:  49.55

Explanation:

The following are the description of the program.

  • Firstly, we declare the empty list type variable 'lst' to store elements.
  • Then, set the for loop statement that iterates from 1 and end at 20.
  • Then, set a variable that get elements of the list from the user and appends those user defined inputs in the list type variable 'lst'.
  • Finally, print the lowest and the largest elements in the list as well as print the total and average of the elements in the list.
fichoh

The program which performs the task described in the question is written in python 3 thus :

mylist = []

#initialize an empty list to hold the values

for n in range(1, 21):

#loop to request 20 inputs from user

n = int(input('Enter a value : '))

mylist.append(n)

#append each value to the list

print('lowest : ' , min(mylist))

print('highest : ' , max(mylist))

print('Total : ' , sum(mylist))

print('Average : ' , sum(mylist)/len(mylist))

#displays the required information

A sample run of the program is attached

Learn more : https://brainly.com/question/19754999

Ver imagen fichoh