1try: 2 str.count 3except AttributeError: 4 print("SKIP") 5 raise SystemExit 6 7# mad.py 8# Alf Clement 27-Mar-2014 9# 10zero = 0 11three = 3 12print("1") 13print("2") 14print(three) 15print("{}".format(4)) 16five = 25 // 5 17print(int(five)) 18j = 0 19for i in range(4): 20 j += i 21print(j) 22print(3 + 4) 23try: 24 a = 4 // zero 25except: 26 print(8) 27print("xxxxxxxxx".count("x")) 28 29 30def ten(): 31 return 10 32 33 34print(ten()) 35a = [] 36for i in range(13): 37 a.append(i) 38print(a[11]) 39print(a[-1]) 40str = "0123456789" 41print(str[1] + str[3]) 42 43 44def p(s): 45 print(s) 46 47 48p("14") 49p(15) 50 51 52class A: 53 def __init__(self): 54 self.a = 16 55 56 def print(self): 57 print(self.a) 58 59 def set(self, b): 60 self.a = b 61 62 63a = A() 64a.print() 65a.set(17) 66a.print() 67b = A() 68b.set(a.a + 1) 69b.print() 70for i in range(20): 71 pass 72print(i) 73if 20 > 30: 74 a = "1" 75else: 76 a = "2" 77if 0 < 4: 78 print(a + "0") 79else: 80 print(a + "1") 81a = [20, 21, 22, 23, 24] 82for i in a: 83 if i < 21: 84 continue 85 if i > 21: 86 break 87 print(i) 88b = [a, a, a] 89print(b[1][2]) 90print(161 // 7) 91a = 24 92while True: 93 try: 94 95 def gcheck(): 96 global a 97 print(a) 98 99 gcheck() 100 101 class c25: 102 x = 25 103 104 x = c25() 105 print(x.x) 106 raise 107 except: 108 print(26) 109 print(27 + zero) 110 break 111print(28) 112k = 29 113 114 115def f(): 116 global k 117 k = yield k 118 119 120print(next(f())) 121while True: 122 k += 1 123 if k < 30: 124 continue 125 break 126print(k) 127for i in [1, 2, 3]: 128 129 class A: 130 def __init__(self, c): 131 self.a = i + 10 * c 132 133 b = A(3) 134 print(b.a) 135print(34) 136p = 0 137for i in range(35, -1, -1): 138 print(i) 139 p = p + 1 140 if p > 0: 141 break 142p = 36 143while p == 36: 144 print(p) 145 p = 37 146print(p) 147for i in [38]: 148 print(i) 149print(int(exec("def foo(): return 38") == None) + foo()) 150d = {} 151exec("def bar(): return 40", d) 152print(d["bar"]()) 153 154 155def fib2(n): 156 result = [] 157 a, b = 0, 1 158 while a < n: 159 result.append(a) 160 a, b = b, a + b 161 return result 162 163 164print(fib2(100)[-2] - 14) 165Answer = {} 166Answer["ForAll"] = 42 167print(Answer["ForAll"]) 168i = 43 169 170 171def f(i=i): 172 print(i) 173 174 175i = 44 176f() 177print(i) 178while True: 179 try: 180 if None != True: 181 print(45) 182 break 183 else: 184 print(0) 185 except: 186 print(0) 187print(46) 188print(46 + 1) 189 190 191def u(p): 192 if p > 3: 193 return 3 * p 194 else: 195 return u(2 * p) - 3 * u(p) 196 197 198print(u(16)) 199 200 201def u49(): 202 return 49 203 204 205print(u49()) 206