Answer to Question #325787 in Python for Kaira

Question #325787

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:

  • find_lowest(list): finds and returns the lowest number in the list. Do not use any built-in function.
  • find_highest(list): finds and returns the highest number in the list. Do not use any built-in function.
  • calculate_total(list): calculates and returns the total of the numbers in the list. Do not use any built-in function.

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


1
Expert's answer
2022-04-08T03:49:03-0400
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}")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS