Python Online Compiler
Example: Python Program to Calculate Total Marks Percentage and Grade of a Student using Nested If else
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# Python Program to Calculate Total Marks Percentage and Grade of a Student using Nested If else print("Enter the marks of five subjects::") subject_1 = float (input ()) subject_2 = float (input ()) subject_3 = float (input ()) subject_4 = float (input ()) subject_5 = float (input ()) total, average, percentage, grade = None, None, None, None # It will calculate the Total, Average and Percentage total = subject_1 + subject_2 + subject_3 + subject_4 + subject_5 average = total / 5.0 percentage = (total / 500.0) * 100 if average >= 90: grade = 'A' else: if average >= 80 and average < 90: grade = 'B' else: if average >= 70 and average < 80: grade = 'C' else: if average >= 60 and average < 70: grade = 'D' else: grade = 'E' # It will produce the final output print ("\nThe Total marks is: \t", total, "/ 500.00") print ("\nThe Average marks is: \t", average) print ("\nThe Percentage is: \t", percentage, "%") print ("\nThe Grade is: \t", grade)
97 96 92 88 85
Output
Clear
ADVERTISEMENTS