Home CPSC 110

Grade Calculator

Objective

To gain experience writing programs which use if, elif and else.


Task

For this lab, you'll be creating a program that converts number grades to letter grades. For instance, if the input to the program is 88.5, the program should output B+.

According to the syllabus for this class, this is the grade breakdown:

This is written using mathematical "range notation". A [ means that is the staring point for a range and it includes that value. A ) means that is the ending point for a range but it does not include that value itself.

For example, to get a B+, you need an 87 or higher, up to a 90, but not including a 90 (which is an A-). So even a 89.999 would count as a B+.


Details

  1. Start by asking the user what their numerical grade is, reading it in as a float (because it can have a fractional part).
  2. Use if, elif, and else statements to test the conditions for each letter grade. In each statement, you can print out the letter grade they receive.
  3. The program should only ever print 1 grade each time you run it. So if you run it twice, it can print different grades, but shouldn't ever print two for the same input.
  4. If the grade is less than 0, print out an error message instead.
  5. There are multiple ways of solving this sort of problem. I'd recommend starting a one side or the other (A or F), and checking them in order.
  6. Be sure to test your program thoroughly, ideally testing each letter grade.

Submitting

When your program is finished, email the .py file to ifinlay@umw.edu.

Copyright © 2018 Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.