Exercise 1 – Grade program written using function
“computergrade(score)”
def computergrade(score):
if score<0 or score>1.0:
print 'Bad score'
else:
if score<=1.0 and score>=0.9:
print "A"
elif score<=0.89 and score>= 0.8:
print "B"
elif score<=0.79 and score>= 0.7:
print "C"
elif score<=0.69 and score>= 0.6:
print "D"
elif score<0.6:
print "F"
else:
print "Bad score"
uservalue=raw_input("Enter score: ")
try:
score = float(uservalue)
computergrade(score)
except:
print "Bad score"
Nema komentara:
Objavi komentar