Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a program that uses a loop to calculate the average score of a given number of quizzes. The program should accept the number of

write a program that uses a loop to calculate the average score of a given number of quizzes.
The program should accept the number of quizzes, and the score for each quiz from the user. Scores should be between 0 to 20 points. They can include decimals.   

The program should satisfy the following conditions:
If the score is lower than 0 (zero), the program should display the message "Enter a score between 0-20 points"
If the score is greater than 20, the program should display the message "Enter a score between 0-20 points"
The output of the average score calculation should include no more than two decimals.  
For example, if the user enters a total number of 5 quizzes and the scores 19.759, 15.40, 13, 10, and 9, the output should display an average score of 13.43 points.

Use the following two examples to test your code:
Expected Output:
How many quizzes? 5
Enter score: 19.759
Enter score: 15.40
Enter score: 13
Enter score: 10
Enter score:  9
The average score is 13.43 points  

Expected output with scores outside of the 0-20 point range:
How many quizzes? 4
Enter score: 12
Enter score: 22
Enter a score between 0-20 points
Enter score: -1
Enter a score between 0-20 points
Enter score: 10
Enter score: 20
Enter score: 19
The average score is 15.25 points  

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Answer The code is as follow def main Prompt the user for the number of qui... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

which of the follwing is a disadvantage of field calibartion?

Answered: 1 week ago