Question
A_MIN_SCORE = 90 B_MIN_SCORE = 80 C_MIN_SCORE = 70 D_MIN_SCORE = 60 # else F # example with printing and nested if def getLetterGradeNestedIf(num_score): if
A_MIN_SCORE = 90
B_MIN_SCORE = 80
C_MIN_SCORE = 70
D_MIN_SCORE = 60 # else F
# example with printing and nested if
def getLetterGradeNestedIf(num_score):
if num_score >= A_MIN_SCORE:
print("grade is A")
else:
if num_score >= B_MIN_SCORE:
print("grade is B")
else:
if num_score >= C_MIN_SCORE:
print("grade is C")
else:
if num_score >= D_MIN_SCORE:
print("grade is D")
else:
print("grade is F")
# example of elif and example of variable to store the score
def getLetterGrade_elif(num_score):
letter_grade = ""
if num_score >= A_MIN_SCORE:
letter_grade = "A"
elif num_score >= B_MIN_SCORE:
letter_grade = "B"
elif num_score >= C_MIN_SCORE:
letter_grade = "C"
elif num_score >= D_MIN_SCORE:
letter_grade = "D"
else:
letter_grade = "F"
return(letter_grade)
numerical_score = int(input("enter numerical grade: "))
print("nested if")
getLetterGradeNestedIf( numerical_score)
print("elif")
print("grade is " + getLetterGrade_elif(numerical_score)) # one way
# another way
result = getLetterGrade_elif(numerical_score)
print("grade is", result)
Choose one of the functions to modify it and create a program that takes the numerical grade as float and that allows B+ and C+.
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