Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 10th, 2012  |  syntax: Python  |  size: 0.47 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/python
  2.  
  3. # P2PU - Python Programming 101 - Chapter 6 - Flow Control
  4. # Python for Informatics - Chapter 3 - Conditional Execution
  5. # Exercise 3.3
  6. print '\n# Exercise 3.3\n'
  7. try:
  8.         num = float(raw_input('Enter a number between 0.0 and 1.0: '))
  9.         if num < 0.0 or num > 1.0 : print 'Bad score!'
  10.         elif num >= 0.9 : print 'A'
  11.         elif num >= 0.8 : print 'B'
  12.         elif num >= 0.7 : print 'C'
  13.         elif num >= 0.6 : print 'D'
  14.         else : print 'F'
  15. except:
  16.   print 'Bad score!'