Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that asks the user to enter avalid score five times. The program should display a letter grade after each score is

Write a program that asks the user to enter avalid score five times. The program should display a letter grade after each score is entered. After all the scores are entered, it should display the average of the scores and the letter grade corresponding to that average. Complete your program by writing the following three functions and calling them from within your main function. get_valid_score This function should ask the user to enter a score. If the score is less than 0 or greater than 100, the function should ask the user to re-enter a score, until the user enters a valid one. Finally, the function returns the valid score. calc_average This function should accept a list of scores as its only argument and return the average of the scores. It should be able to handle lists of any length. determine_grade This function should accept a score as an argument and return a letter grade for the score based on the grading scale in Table la. Score Grade 92-100) A (82-92) B (73-82) C 64-73) D 0-64) F (a) Input Score 89 75 91 82 64 Average Grade (b) Output Grade Terminal $ python avg.grade_login.py Enter a score: 93 The letter grade for 93.0 is A. Enter a score: -7 Invalid Input. Please try again. Enter a score: 101 Invalid Input. Please try again. Enter a score: 100 The letter grade for 100.0 is A. Enter a score: 0: The letter grade for 0.0 is F. Enter a score: 82 The letter grade for 82.0 is B. Enter a score: 65 The letter grade for 65.0 is D. B C B B Results: The average score is 68.00. The letter grade for 68.00 is D. D 80.20 C Input Score 93 -7 101 100 0 82 65 Average Grade (c) Table 1: The grading scale (a), and two test cases (b), and (c) for exercise 04.3. Output Grade A Test your program with the data in Tables Ib and lc. Finally, format your program to match the sample output, character for character, including all white space and punctuation. User input in the sample has been highlighted in Pappy's Purple to distinguish it from the program's output, but your user input does not need to be colored. Save your program as avg_grade_login.py, where login is your Purdue login. Then submit it along with a screen- shot showing a run of both test cases. Invalid Input. Invalid Input. A F B D 68.00 D

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Starting Out With Java From Control Structures Through Data Structures

Authors: Tony Gaddis

6th Edition

0133957055, 978-0133957051

More Books

Students also viewed these Programming questions