Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7ca122a

Browse files
Create Week5_Assignment_3_3.py
1 parent d2798f2 commit 7ca122a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

‎Week5_Assignment_3_3.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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')

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /