Write a program that allows the user to enter a series of exam scores. The number of scores the user can enter is not fixed; they can enter any number of scores they want. The exam scores can be either integers or floats. Then, once the user has entered all the scores they want, your program will calculate and print the average of those scores. After printing the average, the program should terminate. You need to use a while loop to allow the user to enter numbers, one at a time, until some numeric sentinel value is entered. I recommend having a sentinel like 9999, something unlikely to be confused with an exam score. If the user enters a score < 0 or > 100 that is not the sentinel value then that score is to be rejected. Each time a legit score is entered, however, it should be added (appended) to a list. Once the user has entered all the numbers they want, calculate and display the average of the scores rounded to 1 decimal place.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Python approach based on this program

  • Use a while-loop to allow the user to enter any number of exam scores, one number per line, until a sentinel value is entered.
  • Legitimate exam scores should become part of the calculation; bogus scores should be rejected. If a bogus score is entered, offer the user a message asking them to reenter a number..
  • Once all scores have been entered, calculate the average of the scores in any way you see fit. Rounded to 1 decimal place. Once the while loop has ended, then print the number of scores and the score average.
  • Put your name in a comment near the top of the program file.
  • Have the output statement give the number of scores averaged as well as the average itself.
 
Write a program that allows the user to enter a series of exam scores. The number of scores the user can enter is not fixed;
they can enter any number of scores they want. The exam scores can be either integers or floats. Then, once the user has
entered all the scores they want, your program will calculate and print the average of those scores. After printing the average,
the program should terminate.
You need to use a while loop to allow the user to enter numbers, one at a time, until some numeric sentinel value is entered. I
recommend having a sentinel like 9999, something unlikely to be confused with an exam score. If the user enters a score < 0
or > 100 that is not the sentinel value then that score is to be rejected. Each time a legit score is entered, however, it should
be added (appended) to a list.
Once the user has entered all the numbers they want, calculate and display the average of the scores rounded to 1 decimal
place.
Transcribed Image Text:Write a program that allows the user to enter a series of exam scores. The number of scores the user can enter is not fixed; they can enter any number of scores they want. The exam scores can be either integers or floats. Then, once the user has entered all the scores they want, your program will calculate and print the average of those scores. After printing the average, the program should terminate. You need to use a while loop to allow the user to enter numbers, one at a time, until some numeric sentinel value is entered. I recommend having a sentinel like 9999, something unlikely to be confused with an exam score. If the user enters a score < 0 or > 100 that is not the sentinel value then that score is to be rejected. Each time a legit score is entered, however, it should be added (appended) to a list. Once the user has entered all the numbers they want, calculate and display the average of the scores rounded to 1 decimal place.
Here is a possible program run using four scores. The sentinel value here is 9999. You may choose your own wording for the
prompt string and output string.
76 Python Shell
File Edit Shell Debug Options Windows Help
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MS
.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license ()" for more informati
>>>
RESTART
>>>
Calculate the average of a bunch of exam scores.
can be integers or floats
The scores
Enter a number. 9999 to quit: 78.5
Enter a number. 9999 to quit: 80
Enter a number. 9999 to quit: 87.9
Enter a number. 9999 to quit: 71.1
Enter a number. 9999 to quit: 9999
These 4 scores average as: 79.4
>>> |
If the user enters a bogus score, your output should look similar this.
76 Python Shell
File Edit Shell Debug Options Windows Help
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48)
tel)] on win32
Type "copyright", "credits" or "license ()" for more inform
>>>
RESTART
>>>
Calculate the average of a bunch of exam scores.
The scores can be integers or floats
Enter a number. 9999 to quit: 90
Enter a number. 9999 to quit: 138
Score is not in range. Please re-enter.
Enter a number. 9999 to quit: 38
Enter a number. 9999 to quit: 87
Enter a number. 9999 to quit: 9999
These 3 scores average as: 71.7
|>>> |
Transcribed Image Text:Here is a possible program run using four scores. The sentinel value here is 9999. You may choose your own wording for the prompt string and output string. 76 Python Shell File Edit Shell Debug Options Windows Help Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MS .1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license ()" for more informati >>> RESTART >>> Calculate the average of a bunch of exam scores. can be integers or floats The scores Enter a number. 9999 to quit: 78.5 Enter a number. 9999 to quit: 80 Enter a number. 9999 to quit: 87.9 Enter a number. 9999 to quit: 71.1 Enter a number. 9999 to quit: 9999 These 4 scores average as: 79.4 >>> | If the user enters a bogus score, your output should look similar this. 76 Python Shell File Edit Shell Debug Options Windows Help Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) tel)] on win32 Type "copyright", "credits" or "license ()" for more inform >>> RESTART >>> Calculate the average of a bunch of exam scores. The scores can be integers or floats Enter a number. 9999 to quit: 90 Enter a number. 9999 to quit: 138 Score is not in range. Please re-enter. Enter a number. 9999 to quit: 38 Enter a number. 9999 to quit: 87 Enter a number. 9999 to quit: 9999 These 3 scores average as: 71.7 |>>> |
Expert Solution
Python code

Computer Science homework question answer, step 1, image 1

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Basics of loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education