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:
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...
-
For the frame and loading shown, determine the components of the forces acting on member CDE at C and D. 320 mm 100 N 30 B 160 mm 30 D. 160 mm 240 mm 80 mm
-
Find an equation of the tangent plane to the given surface at the specified point. z = e xy , (2, 2, 1)
-
Under IFRS, for non-financial companies, most non-current assets are measured at: A. Fair value. B. The lower of cost or fair value. C. Cost less depreciation and impairment. D. Net realisable value.
-
Prepare all journal entries (budgetary and actual) required in all funds and the GCA-GLTL accounts to record the following transactions and events: 1. The county sold old equipmentoriginal cost...
-
PLAN FOR A SOCIAL BUSINESS The company and especially its top management are the brand. The objective of your social business campaign is to externally promote brand mission imagery and build brand...
-
Make a list of assumptions that will be used as the basis for planning the wedding. And no, it is not acceptable to assume that Tony and Peggy Sue will just elope, no matter how tempting that may be!...
-
Sandra's desk has a number of paper clips, staples and binder clips. If the ratio of paper clips to binder clips is 5 to 2 and the ratio of staples to paper clips is 5 to 1, what is the ratio of...
-
A study wishes to measure "citizen trust in government" through the number of lawsuits filed against the federal government. Evaluate the measurement validity of this approach.
-
Congratulations on reaching the end of the course! Now it is time to reflect upon what you have learned. This course has introduced various topics regarding critical thinking. Reflect upon the...
-
Re-write the following Cartesian equation as an equation in polar form: x + y = -9y NOTE: answer should be in the form r = f(e), for example r = 9 cos NOTE: type 'theta' for the variable
-
When a committee of the California state legislature calls upon managers of state government agencies to testify regarding how they are implementing the laws under their jurisdiction, this is known...
-
If the appropriate substitution is made for the Bernoulli equation below, what will be the integrating factor of the resulting equation? -2x dy dz =ye (ye)3-y
-
Distinguish between poikilothermous and homoeothermous animals. Give example
-
Show that the block upper triangular matrix A in Example 5 is invertible if and only if both A 11 and A 22 are invertible. Data from in Example 5 EXAMPLE 5 A matrix of the form A = [ A11 A12 0 A22 is...
-
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...
-
In the summer of 2015, Stephen Kuhl and Kabeer Chopra made their way to Philadelphia to prepare for business school. It was their first semester in the Wharton MBA program. They were both in an...
-
Juni Learning, the focal firm of the You Be the VC 11.2 feature, provides kids 7 to 18 years old online STEM courses in coding, storytelling, investing, and entrepreneurship. Skip ahead to read the...
-
As noted in this text, the Maker Movement refers to the renewed interest in the United States and elsewhere for people to invent, design, and make things in their homes or in collaborative...
Study smarter with the SolutionInn App