SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Tony Gaddis
Chapter:
Lists And Tuples
Exercise:
Programming Exercises
Question:4 | ISBN:9780132576376 | Edition: 2

Question

Number Analysis Program
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

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

Number Analysis Program Code:

#initialize the numbers
numbers = []

# Prompt and ask user to enter 20 numbers
print(f"Enter a series of 20 numbers:")
for _ in range(20):
    number = float(input("Enter a number number: "))
    numbers.append(number)

# Calculate lowest, highest, total, and average
lowestNum = min(numbers)
highestNum = max(numbers)
totalNum = sum(numbers)
average = totalNum / len(numbers)

# Display the results
print(f"\nLowest number: {lowestNum}")
print(f"Highest number: {highestNum}")
print(f"Total of the numbers: {totalNum}")
print(f"Average of the numbers: {average}")

Executed Output:

Enter a series of 20 numbers:
Enter a number number: 10
Enter a number number: 20
Enter a number number: 30
Enter a number number: 40
Enter a number number: 50
Enter a number number: 60
Enter a number number: 5
Enter a number number: 6
Enter a number number: 10
Enter a number number: 22
Enter a number number: 25
Enter a number number: 23
Enter a number number: 15
Enter a number number: 18
Enter a number number: 20
Enter a number number: 25
Enter a number number: 22
Enter a number number: 11
Enter a number number: 15
Enter a number number: 20

Lowest number: 5.0
Highest number: 60.0
Total of the numbers: 447.0
Average of the numbers: 22.35

 

0 0

Discussions

Post the discussion to improve the above solution.