Question: Please edit the following python code to result functionally. No input function, please do not copy other provided answers. Prompt: Write a program that calls

Please edit the following python code to result functionally. No input function, please do not copy other provided answers.

Prompt: Write a program that calls the following functions to produce the output shown below. calcavg(): takes five grades as parameters and returns the average. getletter(): take the average as a parameter and return the letter grade. You can use the following table to find the letter grades. printresults(): takes the average and letter grade as parameters, and prints the output as shown below. The program before calling the functions should verify the grades and make sure all the grades are numeric. If there are non-numeric grades, it should display the proper message to the user.

Numeric Grade Letter Grade
>=90 A
>=80 B
>=70 C
>=60 D
<60 F

Input:

a) python C:\Users eda\DataProgramming\M4\assign4-9.py 56 70 80 99 66

b) python C:\Users eda\DataProgramming\M4\assign4-9.py 83 90 78 98 97

c) python C:\Users eda\DataProgramming\M4\assign4-9.py 56 70 test 99 66

Output:

a) Average: 74.2 Letter grade: C

b) Average: 89.2 Letter grade: B

c) Error, all grades must be numeric.

Python:

import sys import math

def calcavg(num1,num2,num3,num4,num5): return (num1+num2+num3+num4+num5)/5

def getLetter(marks): if(percentage>=90): return "A" elif(percentage>=80 and marks<90): return "B" elif(percentage>=70 and marks<80): return "C" elif(percentage>=60 and marks<70): return "D" elif(percentage<60): return "F"

def printresults(average,grade): print("Average: "+str(avg)) print("Letter grade: "+str(letter)) avg = round((grade1+grade2+grade3+grade4+grade5)/5, 2) grade1 = int(sys.argv[1]) grade2 = int(sys.argv[2]) grade3 = int(sys.argv[3]) grade4 = int(sys.argv[4]) grade5 = int(sys.argv[5])

letter = getLetter(avg) printresults(avg,letter)

except ValueError: print("Error, all grades must be numeric")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!