Advertisement
dvdjaco

3.3

Feb 21st, 2012
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. # #!/usr/bin/python
  2. #
  3. # By dvdjaco
  4. # Exercise 3.3
  5. #
  6. # Write a program to prompt for a score between 0.0 and 1.0. If the score is out of
  7. # range print an error. If the score is between 0.0 and 1.0, print a grade using the following table:
  8. # Score Grade
  9. # >= 0.9 A
  10. # >= 0.8    B
  11. # >= 0.7    C
  12. # >= 0.6    D
  13. # < 0.6 F
  14. #
  15.  
  16. prompt = "Enter score: "
  17. try:
  18.     score = float(raw_input(prompt))
  19.        
  20.     if score < 0.0 or score > 1.0:
  21.         print "Bad score"
  22.     else:
  23.         if score >= 0.9: print "A"
  24.         elif score >= 0.8: print "B"
  25.         elif score >= 0.7: print "C"
  26.         elif score >= 0.6: print "D"
  27.         else: print "F"
  28. except:
  29.     print "Bad score"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement