Founding Batch Offer ยท HLD ยท LLD ยท System Design at โ‚น799 until 30 Nov

Grade System

Assign a letter grade from a percentage. Students separate reading a percentage from averaging marks and trace the same descending cutoff policy at boundaries.

BeginnerPhase 6 - Category 5: Real-World Logic ProblemsExample 12 of 15
grade-system.py
1# Take percentage
2percentage = float(input("Enter percentage: "))
3
4# Determine grade
5if percentage >= 90:
6 grade = 'A'
7elif percentage >= 80:
8 grade = 'B'
9elif percentage >= 70:
10 grade = 'C'
11elif percentage >= 60:
12 grade = 'D'
13else:
14 grade = 'F'
15
16print(f"Grade: {grade}")

Output

Enter percentage: 85
Grade: B

In this one

  • Read an existing percentage
  • Apply descending bands
  • Separate grading from averaging

How it works

  1. 1

    Convert percentage input to float.

  2. 2

    Test cutoffs ninety, eighty, seventy, then sixty.

  3. 3

    Store and print the first matching grade or F.

Edge cases

What grade does 80 receive?

What grade does 80 receive?

B.

Does this calculate the percentage from marks?

Does this calculate the percentage from marks?

No. It reads the percentage directly.

What's going on

This program receives a percentage already calculated elsewhere. It assigns grade through ordered comparisons rather than reading individual subject marks.

Ninety and above gets A; later cutoffs cover B, C, and D before the final F. The first successful test ends the chain. The prompt does not validate a zero-to-one-hundred range, so impossible percentages still receive labels under the same numeric rules.

What grade does 80 receive? B.

Does this calculate the percentage from marks? No. It reads the percentage directly.

Quiz

Tap an option. The answer stays hidden until you pick.

Question 1

Why test ninety before sixty?

Pick an answer to check it.

Question 2

What grade does 80 receive?

Pick an answer to check it.

Questions people ask

What grade does 80 receive?

B.

Does this calculate the percentage from marks?

No. It reads the percentage directly.

Why test ninety before sixty?

A high percentage also exceeds lower cutoffs.