Answer:
Following are the code to this question:
def letter_grade(x): #defining a method letter_grade that accepts one parameter
if x>=50 and x<=40:#defining if block that check value of x greater than 50 and less than 40
print("A")#print value
if x>=30 and x<=39:#defining if block that check value of x greater than 30 and less than 39
print("B")#print value
if x>=20 and x<=29:#defining if block that check value of x greater than 20 and less than 29
print("C")#print value
if x>=10 and x<=19:#defining if block that check value of x greater than 10 and less than 19
print("D")#print value
if x>=0 and x<=9:#defining if block that check value of x greater than 0 and less than 9
print("F")#print value
letter_grade(30) #calling the method letter_grade
Output:
B
Step-by-step explanation:
In the above Python code, a method "letter_grade" is declared, that accepts an integer variable in its parameter, and defined the multiple if block to check the given value, which can be defined as follows:
- In the first, if block, it checks the value of x greater than 50 and less than 40 , if the condition is true it will print the value "A".
- In the second, if block, it checks the value of x greater than 30 and less than 39, if the condition is true it will print the value "B".
- In the third, if block, it checks the value of x greater than 20 and less than 29, if the condition is true it will print the value "C".
- In the fourth, if block, it checks the value of x greater than 10 and less than 19, if the condition is true it will print the value "D".
- In the fifth, if block, it checks the value of x greater than 0 and less than 9, if the condition is true it will print the value "F".
And at the last it call the method.