By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,715 Members | 748 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,715 IT Pros & Developers. It's quick & easy.

Help on simple input output thing in python.

P: 6
Ok, so what I need to is just have it simply print out if the number is between 7 or 13 to print out whats in the quotes... I'm stuck at this point and I can't figure it out cause it won't print anything out. PLEASE HELP :)

Expand|Select|Wrap|Line Numbers
  1. if num_correct < 7 or > 13:
  2.     print 'You got a check in the lab.'
  3. elif num_correct < 3 or > 6:
  4.     print 'You got a minus in the lab.'
  5. elif num_correct < 0 or > 2:
  6.     print 'You got a zero in the lab.'
  7.  
  8. #This is to show the values in the range.
  9. if num_correct == "14":
  10.     print 'You got a plus for the lab.'
  11. elif num_correct == "7" or num_correct == "8" or\
  12. num_correct == "9" or num_correct == "10" or\
  13. num_correct == "11" or num_correct == "12" or\
  14. num_correct == "13":
  15.     print 'You got a check for the lab.'
  16. elif num_correct == "3" or num_correct == "4" or\
  17. num_correct == "5" or num_correct == "6":
  18.     print 'You got a minus for the lab.'
  19. elif num_correct == "0" or num_correct == "1":
  20.     print 'You got a zero for the lab.'
Oct 21 '10 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 621
Note the difference between these two statements
Expand|Select|Wrap|Line Numbers
  1. if num_correct < 7 or > 13:
  2. elif num_correct == "7" or num_correct == "8" 
An "or" statement is simply an if() + elif()
Expand|Select|Wrap|Line Numbers
  1. if num_correct == "7" or num_correct == "8":
  2.    print "num_correct"
  3. #
  4. # can be expressed as
  5. if num_correct == "7":
  6.     print "num_correct"
  7. elif num_correct == "8":
  8.     print "num_correct" 
so the code you posted breaks down into
Expand|Select|Wrap|Line Numbers
  1. if num_correct < 7 or > 13:
  2. #
  3. # can also be expressed by
  4. if num_correct < 7:
  5.     print "#1 num_correct:
  6. elif > 13:
  7.     print "#2 num_correct"
  8.  
Oct 21 '10 #2

P: 6
Ok thank you so much... I also talked to my teacher about it and he pretty much said the same thing. thanks for you help.
Oct 21 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.