File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ '''Write a program to prompt for a score between 0.0 & 1.0.
2+ If the score is out of range, print an error.
3+ If the score is between 0.0 & 1.0, print the grade using the following table:
4+ >= 0.9 Grade A
5+ >= 0.8 Grade B
6+ >= 0.7 Grade C
7+ >= 0.6 Grade D
8+ < 0.6 Garade F'''
9+
10+ #take input
11+ sc = input ('Enter score: ' )
12+
13+ #check for valid input
14+ try :
15+ vsc = float (sc )
16+ except :
17+ print ('Score must be a neumeric value between 0.0 & 1.0' )
18+ quit ()
19+
20+ #if input is valid, evaluate the grade
21+ if (vsc > 0.0 and vsc < 0.6 ):
22+ print ('F' )
23+ elif (vsc >= 0.6 and vsc < 0.7 ):
24+ print ('D' )
25+ elif (vsc >= 0.7 and vsc < 0.8 ):
26+ print ('C' )
27+ elif (vsc >= 0.8 and vsc < 0.9 ):
28+ print ('B' )
29+ elif (vsc >= 0.9 and vsc <= 1.0 ):
30+ print ('A' )
31+ else :
32+ print ('Score must be between 0.0 & 1.0' )
You can’t perform that action at this time.
0 commit comments