ifcond.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # test if conditions which are optimised by the compiler
  2. if 0:
  3. print(5)
  4. else:
  5. print(6)
  6. if 1:
  7. print(7)
  8. if 2:
  9. print(8)
  10. if -1:
  11. print(9)
  12. elif 1:
  13. print(10)
  14. if 0:
  15. print(11)
  16. else:
  17. print(12)
  18. if 0:
  19. print(13)
  20. elif 1:
  21. print(14)
  22. if 0:
  23. print(15)
  24. elif 0:
  25. print(16)
  26. else:
  27. print(17)
  28. if not False:
  29. print('a')
  30. if not True:
  31. print('a')
  32. else:
  33. print('b')
  34. if False:
  35. print('a')
  36. else:
  37. print('b')
  38. if True:
  39. print('a')
  40. if (1,):
  41. print('a')
  42. if not (1,):
  43. print('a')
  44. else:
  45. print('b')
  46. f2 = 0
  47. def f(t1, t2, f1):
  48. if False:
  49. print(1)
  50. if True:
  51. print(1)
  52. if ():
  53. print(1)
  54. if (1,):
  55. print(1)
  56. if (1, 2):
  57. print(1)
  58. if t1 and t2:
  59. print(1)
  60. if (t1 and t2): # parsed differently to above
  61. print(1)
  62. if not (t1 and f1):
  63. print(1)
  64. if t1 or t2:
  65. print(1)
  66. if (t1 or t2): # parse differently to above
  67. print(1)
  68. if f1 or t1:
  69. print(1)
  70. if not (f1 or f2):
  71. print(1)
  72. if t1 and f1 or t1 and t2:
  73. print(1)
  74. if (f1 or t1) and (f2 or t2):
  75. print(1)
  76. f(True, 1, False)