Easy
Nested selection
Letter grade
Read a score from 0 to 100 and DISPLAY its letter grade:
A for 90 or more, B for 80 to 89, C for 70 to 79, and F below 70.
| Input (one value per INPUT ()) | Expected output |
|---|---|
| 95 | A |
| 80 | B |
Check runs all 4 tests. Press Run to try the program yourself: a box asks for each INPUT ().
Output
Variables
Robot grid The triangle is the robot, the star is the goal, dark squares are walls.
Check
| Test | Input | Expected | Your output |
|---|
Show a solution
score ← INPUT () IF (score ≥ 90) { DISPLAY ("A") } ELSE { IF (score ≥ 80) { DISPLAY ("B") } ELSE { IF (score ≥ 70) { DISPLAY ("C") } ELSE { DISPLAY ("F") } } }
Teachers: sign in as a teacher to add this exercise to a class, graded automatically.
Frequently asked questions
How do I solve this exercise?
Complete the starter code in the editor, press Run to try it (type values when INPUT () asks), then press Check to run every test. Step shows the program line by line with its variables.
Where is the solution?
Under the editor, in Show a solution. Try the exercise first: comparing your code with the solution afterwards is a good way to learn another approach.
AP is a trademark registered by the College Board, which is not affiliated with, and does not endorse, this site.