Help on simple input output thing in python.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jeremy Rohrer
    New Member
    • Oct 2010
    • 6

    Help on simple input output thing in python.

    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 :)

    Code:
    if num_correct < 7 or > 13:
        print 'You got a check in the lab.'
    elif num_correct < 3 or > 6:
        print 'You got a minus in the lab.'
    elif num_correct < 0 or > 2:
        print 'You got a zero in the lab.'
    
    #This is to show the values in the range.
    if num_correct == "14":
        print 'You got a plus for the lab.'
    elif num_correct == "7" or num_correct == "8" or\
    num_correct == "9" or num_correct == "10" or\
    num_correct == "11" or num_correct == "12" or\
    num_correct == "13":
        print 'You got a check for the lab.'
    elif num_correct == "3" or num_correct == "4" or\
    num_correct == "5" or num_correct == "6":
        print 'You got a minus for the lab.'
    elif num_correct == "0" or num_correct == "1":
        print 'You got a zero for the lab.'
    Last edited by Atli; Oct 21 '10, 05:32 AM. Reason: Please use [code] tags when posting code.
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    Note the difference between these two statements
    Code:
    if num_correct < 7 or > 13:
    elif num_correct == "7" or num_correct == "8"
    An "or" statement is simply an if() + elif()
    Code:
    if num_correct == "7" or num_correct == "8":
       print "num_correct"
    #
    # can be expressed as
    if num_correct == "7":
        print "num_correct"
    elif num_correct == "8":
        print "num_correct"
    so the code you posted breaks down into
    Code:
    if num_correct < 7 or > 13:
    #
    # can also be expressed by
    if num_correct < 7:
        print "#1 num_correct:
    elif > 13:
        print "#2 num_correct"

    Comment

    • Jeremy Rohrer
      New Member
      • Oct 2010
      • 6

      #3
      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.

      Comment

      Working...