-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathexam_results.py
More file actions
49 lines (43 loc) · 1.08 KB
/
exam_results.py
File metadata and controls
49 lines (43 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# This program interactively asks about your exam marks, and reports the
# corresponding grades.
#
# Usage:
#
# $ python exam_results.py
#
# A session with the program might look like the following:
#
# $ python exam_results.py
# What marks did you get in Maths?
# > 63
# What marks did you get in Philosophy?
# > 54
# What marks did you get in Geography?
# > 71
# What marks did you get in Music?
# > 68
#
# Your grades:
#
# Maths: B
# Philosophy: C
# Geography: A
# Music: B
subjects = ['Maths', 'Philosophy', 'Geography', 'Music']
grade_boundaries = {
'A': [70, 100],
'B': [60, 69],
'C': [50, 59],
'D': [40, 49],
'E': [30, 39],
'F': [0, 29],
}
print('This program will ask you your marks in the following subjects:')
for subject in subjects:
print(' * {}'.format(subject))
# TODO:
# * Implement the program as described in the comments at the top of the file.
# TODO (extra):
# * Modify the program to handle the case where the user enters an invalid mark
# (such as 150, or -25.5, or "bananas")
# * Modify the program to ask the user for the subjects that they've taken.