paul@638 | 1 | def no_temp(a, b): |
paul@638 | 2 | return not (a and b) |
paul@638 | 3 | |
paul@639 | 4 | def uses_temp(a, b): |
paul@639 | 5 | return a and b |
paul@639 | 6 | |
paul@639 | 7 | def also_uses_temp(a, b): |
paul@639 | 8 | return a or b |
paul@639 | 9 | |
paul@631 | 10 | a = 1 |
paul@631 | 11 | b = 2 |
paul@639 | 12 | c = uses_temp(a, b) |
paul@631 | 13 | print c # 2 |
paul@631 | 14 | |
paul@639 | 15 | d = also_uses_temp(a, b) |
paul@631 | 16 | print d # 1 |
paul@631 | 17 | |
paul@631 | 18 | e = not a |
paul@631 | 19 | print e # False |
paul@631 | 20 | |
paul@637 | 21 | f = 0 |
paul@637 | 22 | |
paul@638 | 23 | g = no_temp(a, b) |
paul@638 | 24 | print g # False |
paul@638 | 25 | |
paul@631 | 26 | if a and b: |
paul@631 | 27 | print "a and b" # a and b |
paul@637 | 28 | else: |
paul@637 | 29 | print "! (a and b)" |
paul@637 | 30 | |
paul@637 | 31 | if a and f: |
paul@637 | 32 | print "a and f" |
paul@637 | 33 | else: |
paul@637 | 34 | print "! (a and f)" # ! (a and f) |
paul@631 | 35 | |
paul@631 | 36 | if not (a and b): |
paul@637 | 37 | print "not (a and b)" |
paul@637 | 38 | else: |
paul@637 | 39 | print "! (not (a and b))" # ! (not (a and b)) |
paul@631 | 40 | |
paul@631 | 41 | if not not (a and b): |
paul@631 | 42 | print "not not (a and b)" # not not (a and b) |
paul@637 | 43 | else: |
paul@637 | 44 | print "! (not not (a and b))" |
paul@631 | 45 | |
paul@631 | 46 | if a or b: |
paul@631 | 47 | print "a or b" # a or b |
paul@637 | 48 | else: |
paul@637 | 49 | print "! (a or b)" |
paul@631 | 50 | |
paul@631 | 51 | if not (a or b): |
paul@637 | 52 | print "not (a or b)" |
paul@637 | 53 | else: |
paul@637 | 54 | print "! (not (a or b))" # ! (not (a or b)) |
paul@631 | 55 | |
paul@631 | 56 | if not not (a or b): |
paul@631 | 57 | print "not not (a or b)" # not not (a or b) |
paul@637 | 58 | else: |
paul@637 | 59 | print "! (not not (a or b))" |
paul@637 | 60 | |
paul@637 | 61 | if a and b or f: |
paul@637 | 62 | print "a and b or f" # a and b or f |
paul@637 | 63 | else: |
paul@637 | 64 | print "! (a and b or f)" |