Question
I am currently trying to make my program work into two functions with a simple a GPA calculator on Python. I must create a function
I am currently trying to make my program work into two functions with a simple a GPA calculator on Python. I must create a function that has one parameter (it accepts one string as input) and returns a number. The purpose of this function is to convert the letter grade into the numeric equivalent. This function should not print anything or prompt the user to enter any values. I will need to call this function four (4) times in my program.
I will then create another function that has one parameter (it accepts one number as input) and returns a string. The purpose of this function is to produce a message about the graduation status when given a GPA. This function should not print anything itself or prompt the user to enter any values.
After I have calculated the GPA, I will call this second function to get the message that should be shown to the user and then print it. Here is my code so for, I am having a hard time crating the two functions that go in there.
sum1=0.0
for i in range(4):
e=input("Enter a grade: ")
if(e=="A"):
sum1=sum1+4.0
elif(e=="B"):
sum1=sum1+3.0
elif(e=="C"):
sum1=sum1+2.0
elif(e=="D"):
sum1=sum1+1.0
elif(e=="F"):
sum1=sum1+0.0
else:
sum1=sum1
sum1=sum1/4
print("GPA is "+str(sum1))
if(sum1>=3.2 and sum1
print("Student can graduate Ccum laude.")
elif(sum1>=3.6 and sum1
print("Student can graduate magna Ccum laude.")
elif(sum1=3.8>
print("Student can graduate Summa Ccum laude.")
elif(sum1>=2.0 and sum1
print("Student is eligible to graduate.")
else:
print("Student cannot graduate.")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
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