Advertisement
Guest User

P2PU Python Course: ex.4.7

a guest
Mar 26th, 2013
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Mar 26 13:07:49 2013
  4. Exercise 4.7
  5. @author: casa
  6. """
  7. def computegrade(s):
  8.     if s > 1 :
  9.         g = 'None'
  10.     elif s > 0.9 :
  11.         g = 'A'
  12.     elif s > 0.8 :
  13.         g = 'B'
  14.     elif s > 0.7 :
  15.         g = 'C'
  16.     elif s > 0.6 :
  17.         g = 'D'
  18.     else :
  19.         g = 'F'
  20.     return g
  21.    
  22. while (True):
  23.     score = raw_input("Enter score: ")
  24.     if score == "done" :
  25.         print("Bye bye")
  26.         break    
  27.     try:
  28.         print score
  29.         score = float(score)
  30.         grade = computegrade(score)
  31.     except:
  32.         print("Bad score")
  33.         continue
  34.     print("Grade: "), grade
  35. exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement