All lessons

Making decisions · step 11 of 22

Lab: grading a test

Sign in if you want this lab saved to your progress.

Grade the test

Three scores are in. Work out the average and turn it into a letter grade — the way a teacher's spreadsheet would.

Given for you: test1, test2, test3

Build:

  • average — the mean of the three scores, rounded to 1 decimal
  • grade — A for 90+, B for 80+, C for 70+, D for 60+, otherwise F

Print the average, then the grade, one per line.

The autograder reruns your program with different scores, so write the rules once and use variables — never the numbers 88, 92 and 79 directly.

Build it

Fill in the code, then run it. Every check has to pass for the lab to count.

lab-grade-calculator.py

Given for you

test1 = 88
test2 = 92
test3 = 79