Write a program that asks the user to enter avalid score five times. The program should...
Fantastic news! We've Found the answer you've been seeking!
Question:
![](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/09/65005e1f77a80_1694522908893.jpg)
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Starting Out With Java From Control Structures Through Data Structures
ISBN: 9780133957051
6th Edition
Authors: Tony Gaddis
Posted Date:
Students also viewed these programming questions
-
Order the planning methodsor strategiesthat would be suitable for implementing technology within an organization. (a) Discuss contingencies to take risks into account (b) Define the...
-
Alpha Company used the periodic inventory system for purchase & sales of merchandise. Discount terms for both purchase & sales are, FOB Destination, 2/10, n30 and the gross method is used. > Alpha...
-
Sweeten Company had no jobs in progress at the beginning of the year and no beginning inventories. It started, completed, and sold only two jobs during the year-Job P and Job Q. The company uses a...
-
Consider the integral where n is an integer. Using the trigonometric identity 1 + tan 2 x = sec 2 x, show that and hence obtain the recurrence relation Use this to find (Recurrence relations of this...
-
Burke Bros. began operations on January 1, 2014. Its fiscal year end is December 31 and it prepares financial statements and adjusts its accounts annually. Selected transactions from 2014 follow: 1....
-
A multiple regression with 36 observations and three explanatory variables yields the ANOVA table in Table 11.1. a. Complete this ANOVA table. b. Can you conclude at the 1% significance level that...
-
Product mix under constraint (Learning Objective 5) Easy Living of Charlotte, North Carolina, specializes in outdoor furniture and spas. Owner Linda Spring is expanding the store. She is deciding...
-
As a long-term investment, Painters' Equipment Company purchased 20% of AMC Supplies Inc.'s 400,000 shares for $480,000 at the beginning of the fiscal year of both companies. On the purchase date,...
-
\f
-
Dippin Donuts has six bakers and a bakery supervisor on each of its two shifts. Bakers working from 8am 5pm (with a 1-hour break) are paid $6.00 per hour. Bakers working the 10pm-7am shift (with a...
-
23:58 The function f(x)-80,000+0.2 yields the average cost in dollars for a company to produce x copies of a comic book Which statement best fits the situation modeled by the function? The company...
-
Charitable contributions are typical state adjustments: true or false?
-
State and local taxes on income are typical state adjustments: true or false?
-
What are the most important state and local taxes in your state?
-
Galadriel Elvin, a wealthy entrepreneur, is returning home after taking the eldest of her three children to start college on the other side of the country when she notices that the person sitting...
-
Avoiding the need for audits is one reason why organizations develop clearly documented policies, standards, and procedures. A. True B. False
-
Let g(y) = (y + 1)(y+3) (y - 9) Use logarithmic differentiation to determine the derivative of g. Dy[g(y)] =
-
Do the three planes x + 2x + x 3 = 4, X X 3 = 1, and x + 3x = 0 have at least one common point of intersection? Explain.
-
What is the purpose of the argument that is passed to an exception objects constructor? What happens if you do not pass an argument to the constructor?
-
Look at the following class declarations and answer the questions that follow them: public class Shape { Private double area; Public void setArea(double a) { Area = a; } Public double getArea() {...
-
What is the difference between using the Applet method asked for in Checkpoint 14.35, and using an AudioClip object to play a sound file? Data in Checkpoint 14.35 What Applet method can you use to...
-
The total assets and liabilities at the beginning and end of the year for Luther Company are listed below. Determine Luther Companys net income or loss for the year under each of the following...
-
Below is information from the statement of retained earnings of Mrs. Bells Cookies, Inc. for a recent year. Prepare the statement of retained earnings for Mrs. Bells Cookies in good form. You will...
-
Primorsk Corporation began the year 20x6 with cash of $55,900. In addition to earning a net income of $32,500 and paying a cash dividend of $19,500, Primorsk borrowed $78,000 from the bank and...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App