Write a Python program that asks the user to enter a series of 20 numbers. The program should store the numbers in a list. It should have the following functions:
The program should call the functions mentioned above and display the lowest, highest and total values in the list. It should also calculate and display the average of the numbers in the list
def find_lowest(list):
low = list[0]
for i in range(1, len(list)):
if low > list[i]:
low = list[i]
return low
def find_highest(list):
high = list[0]
for i in range(1, len(list)):
if high < list[i]:
high = list[i]
return high
def calculate_total(list):
total = 0
for i in range(len(list)):
total += list[i]
return total
arr = [0]*20
print("Enter a series of 20 numbers:")
for i in range(20):
arr[i] = int(input())
print(arr)
print(f"\nLowest number in the list: {find_lowest(arr)}")
print(f"\nHighest number in the list: {find_highest(arr)}")
print(f"\nTotal of the numbers in the list: {calculate_total(arr)}")
print(f"\nAverage of the numbers in the list: {calculate_total(arr) / 20}")
Comments
Leave a comment