Python Online Compiler
Example: Python Program to Find Grade and Average Marks of a Student Using Function
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# Python Program to Find Grade and Average Marks of a Student Using Function # Custom function to Display Percentage & Grade def CalcPercentGrade (S_1, S_2, S_3, S_4, S_5): # It will calculate the Total, Average and Percentage total = S_1 + S_2 + S_3 + S_4 + S_5 average = total / 5.0 percentage = (total / 500.0) * 100 if average >= 90: grade = 'A' elif average >= 80 and average < 90: grade = 'B' elif average >= 70 and average < 80: grade = 'C' elif 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) # Driver function to Run this Program 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 produce the final output CalcPercentGrade (subject_1, subject_2, subject_3, subject_4, subject_5)
97 96 92 88 85
Output
Clear
ADVERTISEMENTS