Python Program to Calculate Percentage and Grade | Marks Input Example with Code

SOLUTION.

# Python Program to Calculate Percentage and Grade # Input marks for five subjects physics = float(input("Enter marks in Physics: ")) chemistry = float(input("Enter marks in Chemistry: ")) biology = float(input("Enter marks in Biology: ")) mathematics = float(input("Enter marks in Mathematics: ")) computer = float(input("Enter marks in Computer: ")) # Calculate total and percentage total = physics + chemistry + biology + mathematics + computer percentage = (total / 500) * 100 # Assuming each subject is out of 100 # Determine grade based on percentage if percentage >= 90: grade = 'A' elif percentage >= 80: grade = 'B' elif percentage >= 70: grade = 'C' elif percentage >= 60: grade = 'D' elif percentage >= 40: grade = 'E' else: grade = 'F' # Display the results print("\n----- Result -----") print(f"Total Marks: {total}/500") print(f"Percentage: {percentage:.2f}%") print(f"Grade: {grade}")

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.