Foundations Conditions
586. Grade from Marks
Easy
You are given a student's marks in a test, an integer marks from 0 to 100. Return the student's grade as a
one-letter string:
"A"for 90 to 100"B"for 80 to 89"C"for 70 to 79"D"for 60 to 69"F"for anything below 60
Each range includes both of its ends. Answers are shown in double quotes.
Example 1
Input: marks = 89
Output:
"B"Explanation: 89 falls in the range 80 to 89. It is one mark short of an A.
Example 2
Input: marks = 100
Output:
"A"Explanation: 100 is the highest mark, and it is the top end of the range 90 to 100.
Example 3
Input: marks = 59
Output:
"F"Explanation: 59 is below 60. It is one mark short of a D.
Check your understanding
Work out the answer for this input before you write any code.
marks = 80
Constraints
0 ≤ marks ≤ 100
Clarifying questions
What you would ask an interviewer before writing any code.