Docsity

how to make programming, Cheat Sheet of Computer science

Toggle sidebar
bg1
Grade generator program activity (Covers Pass (P6), Merit(M3) or Distinction(D2)
depending on the quality of your code):
Write a program in Python that reads in an exam mark and displays the relevant grade. The
grade boundaries are…
0 to 39 marks Grade U
40 to 49 marks Grade E
50 to 59 marks Grade D
60 to 69 marks Grade C
70 to 79 marks Grade B
80 to 100 marks Grade A
The user will normally enter a number within the range 0 to 100 (then pressing the Enter key).
In this case, the correct grade should be displayed until the user presses the Enter key again.
If possible, you should make your program display the message “You have to enter a number
between 0 and 100” if any other number is entered (including negative ones).
When you have written and de-bugged your program, you should test it with the following test
data.
Value entered Expected result Actual result
-1 “You have to enter a number
between 0 and 100”
0 U
20 U
39 U
40 E
50 D
65 C
70 B
100 A
101 “You have to enter a number
between 0 and 100”
pf2

Partial preview of the text

Download how to make programming and more Cheat Sheet Computer science in PDF only on Docsity!

Grade generator program activity (Covers Pass (P6), Merit(M3) or Distinction(D2) depending on the quality of your code): Write a program in Python that reads in an exam mark and displays the relevant grade. The grade boundaries are… 0 to 39 marks Grade U 40 to 49 marks Grade E 50 to 59 marks Grade D 60 to 69 marks Grade C 70 to 79 marks Grade B 80 to 100 marks Grade A The user will normally enter a number within the range 0 to 100 (then pressing the Enter key). In this case, the correct grade should be displayed until the user presses the Enter key again. If possible, you should make your program display the message “You have to enter a number between 0 and 100” if any other number is entered (including negative ones). When you have written and de-bugged your program, you should test it with the following test data. Value entered Expected result Actual result -1 “You have to enter a number between 0 and 100” 0 U 20 U 39 U 40 E 50 D 65 C 70 B 100 A 101 “You have to enter a number between 0 and 100”

Extension task (M3 ) – Improve your Code for the above program to include a loop (For Loop or While Loop). Extension task (D2 ) – Improve your Code for the above program to include a function.