PYTHON PROGRAM a. Write a modular program, that accepts a series of 3 test grades, validates each test grade (to be in the range 0-
PYTHON PROGRAM
a. Write a modular program, that accepts a series of 3 test grades, validates each test grade (to be in the range 0- 100). The program should store the test grades in a list and then determine the following data calling appropriate functions as described in step 4b below (do not use standard functions like min, max, sum, sort, etc.!):
The lowest test grade in the list
The highest test grade in the list
The average of the test grades in the list
Letter grade of the average test grade
b. The program should display the output/results including the lowest, highest, average test grade (all 3 values formatted to 1 decimal place), and the letter grade (NOTE: Other than the data input, your output should look EXACTLY like in the below table showing a few sample runs for you to compare, the items shown after the colon symbol are what you enter as input; those items can vary for each sample run):
b. Below the top comment block, type the actual python code for the problem described in step 3. Make sure to include the functions as described below EXACTLY! (Refer to the sample code screenshot below with function calls and definition examples and HINTS):
a. main() This should be the first and foremost function called and defined (Refer to line #s 68 and 13 - 20 in the below sample code screenshot on how this function is called, and HINTS for how other functions should be called in the main function definition)
b. get_test_list() This should be a value returning function called by main() function, that accepts no arguments. This function asks the user to enter a test grade, validates it (to be in the range 0-100), stores in a list if valid and returns the list back to the main function (Refer to line #s 16 and 22 - 34 HINTS in the below screenshot)
c. lo_grade() This should be a value returning function called by main function, that accepts one list argument. This function should find and return the lowest of the 3 test grades in the list. Remember not to use the min, sort, or any other standard functions available. (Refer to line #s 17 and 36 42 HINTS in the below screenshot)
d. hi_grade() This should be a value returning function called by main function, that accepts one list argument. This function should find and return the highest of the 3 test grades in the list. Remember not to use the max, sort, or any other standard functions available (Refer to line #s 18 and 44 - 49 HINTS in the below screenshot)
e. avg_grade() This should be a value returning function called by main function, that accepts one list argument. This function should find and return the average of the 3 test grades in the list. Remember not to use the sum or any other standard functions available (Refer to line #s 18 and 51 - 56 HINTS in the below screenshot) f. letter_grade() Page 3 of 4 Page 3 of 4 This should be a value returning function called by main function, that accepts one argument avg test grade. This function should find and return the letter grade of the average (Refer to line #s 18 and 58 - 60 HINTS in the below screenshot)
g. display_grades() This should be a void function called by main function that accepts four arguments - lowest test grade, highest test grade, the average test grade (all 3 values formatted up to 1 decimal place), and the letter grade of avg, and displays them (Refer to line #s 20 and 62 - 66 HINTS in the below screenshot) Make sure to include the following in your program as well:
i. Define appropriate/descriptive CONSTANTS (Refer to line #s 8 11 in the below screenshot)
ii. Use appropriate/descriptive variable_names (Refer to line #s 15 17, 23-24, and 37 in the below screenshot)
iii. Have enough documentation for understandability of your program by including a comment block at the beginning of the program (Refer to line #s 1 6 in the below screenshot) and prior to each function describing in your own words the purpose of each function by explaining the logic of loop, if, and other python functions used (refer to Textbook/Instructor EXAMPLE PROGRAMS listed in Canvas Modules)
iv. Have proper indentation and line spacing for readability of your program (refer to Textbook/Instructor EXAMPLE PROGRAMS listed in Canvas Modules)
The sample should be like below but filled:
1 2 Name: Enter your full name here 3 Lab: Chapters 1-7 Review 4 Description: This needs to be at least a paragraph explanation of the program (in your own words) 6 AR 8 # CONSTANTS 9 TITLE = " Welcome to Test Grade Analysis Program! " -"*50 11 SIZE = 3 10 LINE E 12 14 16 13 def main(): print(TITLE+LINE) 15 test_list = [] test_list = get_test_list() 17 lo = lo_grade (test_list) 18 # HINT: Call remaining functions (hi_grade, avg_grade, & letter_grade) below... 19 20 display_grades (1o, hi,avg, grade) 21 22 def get_test_list(): test_list = [] i = 1 # HINT: Complete remaining statements using while loop & if/else as described below... # HINT: Use while loop until i less than or equal to SIZE of list: 27 # HINT: Use input function prompting for a float test grade in range 0-100 28 # HINT: Use if with 'or' operator to check test grade outside range 0-100 # HINT: Use print function with end attribute to display ERROR! # HINT: Use continue statement to go back in the loop 31 # HINT: Use else condition here... 32 # HINT: append the valid test grade to test_list # HINT: increment i by 1 return test_list 23 24 25 26 29 30 33 34 36 def lo_grade(test_list): 37 lo = test_list[@] 38 # HINT: Complete remaining statements as described below (do not use min/sort functions) 39 # HINT: Use a for loop to check test_grade in test_list 40 # HINT: Use if to check test_grade is less than lo 41 # HINT: Then, lo will be equal to test_grade 42 return lo 43 44 # HINT: Define hi_grade function heading here (do not use max/sort functions) 45 # HINT: Initialize hi variable equals to first element of the list 46 # HINT: Use a for loop to check test_grade in test_list 47 # HINT: Use if to check test_grade is greater than hi 48 # HINT: Then, hi will be equal to test_grade 49 # HINT: return hi 50 51 # HINT: Define avg_grade function heading here (do not use sum function) 52 # HINT: Initialize total variable equals to 53 # HINT: Use a for loop to check test_grade in test_list 54 # HINT: Add test_grade to total each time 55 # HINT: find avg by dividing total by SIZE of test_list 56 # HINT: return avg 57 58 # HINT: Define letter_grade function heading here 59 # HINT: Using if/elif/else statement to check if avg is >= 90, 80, 70, 60 60 #HINT: Return appropriate letter grade (A,B,C,D,F) 61 62 def display_grades(lo, hi, avg, grade): 63 print(LINE) 64 # HINT: Use print function to display lo, hi, & avg to 1 decimal place 65 # HINT: Use print function to display grade 66 print(LINE) 67 68 main()Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started