Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: CSCI 195
Views: 5931
Image: ubuntu2004
1
A_boundary = -1
2
B_boundary = -1
3
C_boundary = -1
4
D_boundary = -1
5
6
while D_boundary < 0 or D_boundary > 1:
7
D_boundary = float(raw_input("Enter the minimum percentage required for a 'D' (must be between 0 and 1): "))
8
if (D_boundary < 0) or D_boundary > 1:
9
print 'Sorry, the boundary of', D_boundary, "for a grade of 'D' is invalid.",
10
print "Please try again."
11
12
while C_boundary <= D_boundary or C_boundary > 1:
13
prompt = "Enter the minimum percentage required for a 'C' (must be between %f and 1): " % D_boundary
14
C_boundary = float(raw_input(prompt))
15
if (C_boundary <= D_boundary) or C_boundary > 1:
16
print 'Sorry, the boundary of', C_boundary, "for a grade of 'C' is invalid.",
17
print "Please try again."
18
19
while B_boundary <= C_boundary or B_boundary > 1:
20
prompt = "Enter the minimum percentage required for a 'B' (must be between %f and 1): " % C_boundary
21
B_boundary = float(raw_input(prompt))
22
if (B_boundary <= C_boundary) or B_boundary > 1:
23
print 'Sorry, the boundary of', B_boundary, "for a grade of 'B' is invalid.",
24
print "Please try again."
25
26
while A_boundary <= B_boundary or A_boundary > 1:
27
prompt = "Enter the minimum percentage required for an 'A' (must be between %f and 1): " % B_boundary
28
A_boundary = float(raw_input(prompt))
29
if (A_boundary <= B_boundary) or A_boundary > 1:
30
print 'Sorry, the boundary of', A_boundary, "for a grade of 'A' is invalid.",
31
print "Please try again."
32
33
score1 = -1
34
while score1 < 0 or score1 > 100:
35
score1 = float(raw_input('Enter the score for exam 1: '))
36
if score1 < 0 or score1 > 100:
37
print 'The score must be between 0 and 100. Please re-enter'
38
39
score2 = -1
40
while score2 < 0 or score2 > 100:
41
score2 = float(raw_input('Enter the score for exam 2: '))
42
if score2 < 0 or score2 > 100:
43
print 'The score must be between 0 and 100. Please re-enter'
44
45
score3 = -1
46
while score3 < 0 or score3 > 100:
47
score3 = float(raw_input('Enter the score for exam 3: '))
48
if score3 < 0 or score3 > 100:
49
print 'The score must be between 0 and 100. Please re-enter'
50
51
# Compute the average score and put it into a variable named average_score
52
average_score = (score1 + score2 + score3) / 3
53
average_score_as_percent = average_score / 100
54
55
if average_score_as_percent >= A_boundary:
56
grade = 'A'
57
elif average_score_as_percent >= B_boundary:
58
grade = 'B'
59
elif average_score_as_percent >= C_boundary:
60
grade = 'C'
61
elif average_score_as_percent >= D_boundary:
62
grade = 'D'
63
else:
64
grade = 'F'
65
66
print "Your average score was", average_score, 'for a grade of', grade
67
68