← All Class 11 programs

Grade from marks

Class 11 Computer Science · Conditional Statements · Write the program · 4 marks

  1. Read the question and the sample tests.
  2. Write your Python program in the editor.
  3. Run Code to check it on the sample tests (no marks).
  4. Submit Answer for evaluation: hidden tests award the marks. Nothing is saved here.

Question

Write a program that reads a student's marks (an integer out of 100) and prints the grade using this table: 90 to 100: A 75 to 89: B 60 to 74: C 33 to 59: D 0 to 32: E Marks below 0 or above 100 are invalid. Input: one line, the marks. Output: exactly one line, either Grade: X or Invalid marks

Sample tests

Use these examples to check your program. Your output must match the Expected Output exactly.

Sample 1
Sample Input
92
Expected Output
Grade: A
Sample 2
Sample Input
74
Expected Output
Grade: C

Evaluation: when you submit, your program is also checked against 4 hidden tests that you cannot see. Marks come from the hidden tests only. Each test you pass earns its marks, so a partly correct program gets part marks. Prompt text passed to input() is not counted as output.

Your program

Write the complete program. It must read any input itself and print the result.

Write the whole program, including any import lines it needs. The editor starts empty; Reset Code clears it. Submit your answer before leaving the page.

Loading Python…
Approach (open it after you have tried)

Check the invalid case first, then test the grades from the highest boundary down. In an if-elif chain only the first true branch runs, so after marks >= 90 fails, marks >= 75 already means 75 to 89. The boundary values 90, 75, 60 and 33 belong to the higher grade.

Practise all 65 Class 11 programs

This page has 10 programs. The complete Class 11 Python Lab has 65, and keeps your best score and chapter progress.

Other Class 11 programs: Simple interest · Prime or composite · Alternating series · Right triangle of stars · Palindrome string · Linear search in a list · Search in a tuple · Character frequency with a dictionary · Circle with the math module

CodeBuddy
Hi there! 👋 I'm CodeBuddy, your KV Coders assistant.

To help me give you the most accurate answers, please select your class and subject below, or just type your question!
Buddy is typing...