Computer Science I for majors by James Tam

Return to the course web page

CPSC 231: Mini-Assignment #2

Due Friday October 3, at 4 PM

New Concepts to be applied for the assignment

Description

Write a program that will randomly generate a number from 1 - 6 to simulate the rolling of a six sided die. The value rolled will determine the grade received in a course using the mappings shown in the following table:

Die roll Letter grade
6 A
5 B
4 C
3 D
2 F
1 W

The program should display the letter grade awarded. Also the program should be able to determine if there was an erroneous value generated (outside the range of 1 - 6) and if so display an appropriate error message1.

Submitting your work:

  1. Assignments (source code/'dot-py' file) must be electronically submitted according to [the assignment submission requirements] using [D2L]
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following [link].

Using pre-written Python libraries:

Aside from input()/print() and functions to convert types: str(), float(), int(), unless you are told otherwise, you will need to write your own code and cannot use other pre-written Python functions/methods. Functions that you can use specifically for this assignment include: the methods of the 'random()' library.

Marking key

Feature

Marks

Displays an error message if die roll is too high

1

Displays an error message if die roll is too low

1

Correctly detects and displays messages for each of the 6 possible 'grades' that can be awarded for a course (1 mark for each case)

6

TOTAL

8

Determining your assignment mark: Mapping of Raw score to grade point

Raw score 8 7 6 5 4 3 2 1 0
Grade point 4 3.7 3.3 3 2.7 2.3 2 1 0

1. Although it is unlikely that this error will occur, the lesson is that you should never assume that bugs won't occur. The code to catch the error is therefore necessary.