Answer:
The program to this question as follows:
Program:
score=int(input("Enter your percentage: ")) #input grade by user
#using conditional statement for match condition
if 95<=score <= 100: #if value in between 95 to 100
grade = 'A+' #assign grade
elif 90 <=score <= 94: #elif value in between 90 to 94
grade = 'A' #assign grade
elif 80 <=score <= 89: #elif value in between 80 to 89
grade = 'B+' #assign grade
elif 70 <=score <= 79: #elif value in between 70 to 79
grade = 'B' #assign grade
elif 60 <=score <= 69: #elif value in between 60 to 69
grade = 'C+' #assign grade
elif 50 <=score <= 59: #elif value in between 50 to 59
grade = 'C' #assign grade
elif score<49 : #elif value is less then 49
grade = 'F' #assign grade
print (grade) #print grade
Output:
Enter your percentage: 50
C
Explanation:
In the above python code, a variable "score" is defined, this variable is used for taking value from the user end. In the next step if-elif-else conditional statement is used, this statement is used when a group of statements is given in which one is true. The if block check score value is between 95-100 if this is true it will print A+.
In elif block if the above condition is not true, then this condition will execute, in this block, there are multiple elif block is used that can be described as follows:
- In the first block, if the value in between 90-94. It will print A.
- In the second block, if the value in between 80-89. It will print B+.
- In the third block, if value in between 70-79. It will print B.
- In the fourth block, if value in between 60-69. It will print C+.
- In the fifth block, if value in between 50-59. It will print C.
- In the last, if the value of the score is less then 49. It will print F.