2018-08-30 18:50:04 +01:00
|
|
|
try:
|
|
|
|
str.count
|
|
|
|
except AttributeError:
|
|
|
|
print("SKIP")
|
|
|
|
raise SystemExit
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
# mad.py
|
|
|
|
# Alf Clement 27-Mar-2014
|
|
|
|
#
|
2020-03-23 02:26:08 +00:00
|
|
|
zero = 0
|
|
|
|
three = 3
|
2014-03-31 18:02:22 +01:00
|
|
|
print("1")
|
|
|
|
print("2")
|
|
|
|
print(three)
|
|
|
|
print("{}".format(4))
|
2020-03-23 02:26:08 +00:00
|
|
|
five = 25 // 5
|
2014-03-31 18:02:22 +01:00
|
|
|
print(int(five))
|
2020-03-23 02:26:08 +00:00
|
|
|
j = 0
|
2014-03-31 18:02:22 +01:00
|
|
|
for i in range(4):
|
2020-03-23 02:26:08 +00:00
|
|
|
j += i
|
2014-03-31 18:02:22 +01:00
|
|
|
print(j)
|
2020-03-23 02:26:08 +00:00
|
|
|
print(3 + 4)
|
2014-03-31 18:02:22 +01:00
|
|
|
try:
|
2020-03-23 02:26:08 +00:00
|
|
|
a = 4 // zero
|
2014-03-31 18:02:22 +01:00
|
|
|
except:
|
2020-03-23 02:26:08 +00:00
|
|
|
print(8)
|
2014-03-31 18:02:22 +01:00
|
|
|
print("xxxxxxxxx".count("x"))
|
2020-03-23 02:26:08 +00:00
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
def ten():
|
2020-03-23 02:26:08 +00:00
|
|
|
return 10
|
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
print(ten())
|
2020-03-23 02:26:08 +00:00
|
|
|
a = []
|
2014-03-31 18:02:22 +01:00
|
|
|
for i in range(13):
|
2020-03-23 02:26:08 +00:00
|
|
|
a.append(i)
|
|
|
|
print(a[11])
|
2014-03-31 18:02:22 +01:00
|
|
|
print(a[-1])
|
2020-03-23 02:26:08 +00:00
|
|
|
str = "0123456789"
|
|
|
|
print(str[1] + str[3])
|
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
def p(s):
|
2020-03-23 02:26:08 +00:00
|
|
|
print(s)
|
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
p("14")
|
|
|
|
p(15)
|
2020-03-23 02:26:08 +00:00
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
class A:
|
2020-03-23 02:26:08 +00:00
|
|
|
def __init__(self):
|
|
|
|
self.a = 16
|
|
|
|
|
|
|
|
def print(self):
|
|
|
|
print(self.a)
|
|
|
|
|
|
|
|
def set(self, b):
|
|
|
|
self.a = b
|
|
|
|
|
|
|
|
|
|
|
|
a = A()
|
2014-03-31 18:02:22 +01:00
|
|
|
a.print()
|
|
|
|
a.set(17)
|
|
|
|
a.print()
|
2020-03-23 02:26:08 +00:00
|
|
|
b = A()
|
2014-03-31 18:02:22 +01:00
|
|
|
b.set(a.a + 1)
|
|
|
|
b.print()
|
|
|
|
for i in range(20):
|
2020-03-23 02:26:08 +00:00
|
|
|
pass
|
2014-03-31 18:02:22 +01:00
|
|
|
print(i)
|
|
|
|
if 20 > 30:
|
2020-03-23 02:26:08 +00:00
|
|
|
a = "1"
|
2014-03-31 18:02:22 +01:00
|
|
|
else:
|
2020-03-23 02:26:08 +00:00
|
|
|
a = "2"
|
2014-03-31 18:02:22 +01:00
|
|
|
if 0 < 4:
|
2020-03-23 02:26:08 +00:00
|
|
|
print(a + "0")
|
2014-03-31 18:02:22 +01:00
|
|
|
else:
|
2020-03-23 02:26:08 +00:00
|
|
|
print(a + "1")
|
|
|
|
a = [20, 21, 22, 23, 24]
|
2014-03-31 18:02:22 +01:00
|
|
|
for i in a:
|
2020-03-23 02:26:08 +00:00
|
|
|
if i < 21:
|
|
|
|
continue
|
|
|
|
if i > 21:
|
|
|
|
break
|
|
|
|
print(i)
|
|
|
|
b = [a, a, a]
|
2014-03-31 18:02:22 +01:00
|
|
|
print(b[1][2])
|
2020-03-23 02:26:08 +00:00
|
|
|
print(161 // 7)
|
|
|
|
a = 24
|
2014-03-31 18:02:22 +01:00
|
|
|
while True:
|
2020-03-23 02:26:08 +00:00
|
|
|
try:
|
|
|
|
|
|
|
|
def gcheck():
|
|
|
|
global a
|
|
|
|
print(a)
|
|
|
|
|
|
|
|
gcheck()
|
|
|
|
|
|
|
|
class c25:
|
|
|
|
x = 25
|
|
|
|
|
|
|
|
x = c25()
|
|
|
|
print(x.x)
|
|
|
|
raise
|
|
|
|
except:
|
|
|
|
print(26)
|
|
|
|
print(27 + zero)
|
|
|
|
break
|
2014-03-31 18:02:22 +01:00
|
|
|
print(28)
|
2020-03-23 02:26:08 +00:00
|
|
|
k = 29
|
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
def f():
|
2020-03-23 02:26:08 +00:00
|
|
|
global k
|
|
|
|
k = yield k
|
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
print(next(f()))
|
|
|
|
while True:
|
2020-03-23 02:26:08 +00:00
|
|
|
k += 1
|
|
|
|
if k < 30:
|
|
|
|
continue
|
|
|
|
break
|
2014-03-31 18:02:22 +01:00
|
|
|
print(k)
|
2020-03-23 02:26:08 +00:00
|
|
|
for i in [1, 2, 3]:
|
|
|
|
|
|
|
|
class A:
|
|
|
|
def __init__(self, c):
|
|
|
|
self.a = i + 10 * c
|
|
|
|
|
|
|
|
b = A(3)
|
|
|
|
print(b.a)
|
2014-03-31 18:02:22 +01:00
|
|
|
print(34)
|
2020-03-23 02:26:08 +00:00
|
|
|
p = 0
|
2014-03-31 18:02:22 +01:00
|
|
|
for i in range(35, -1, -1):
|
2020-03-23 02:26:08 +00:00
|
|
|
print(i)
|
|
|
|
p = p + 1
|
|
|
|
if p > 0:
|
|
|
|
break
|
|
|
|
p = 36
|
2014-03-31 18:02:22 +01:00
|
|
|
while p == 36:
|
2020-03-23 02:26:08 +00:00
|
|
|
print(p)
|
|
|
|
p = 37
|
2014-03-31 18:02:22 +01:00
|
|
|
print(p)
|
|
|
|
for i in [38]:
|
2020-03-23 02:26:08 +00:00
|
|
|
print(i)
|
|
|
|
print(int(exec("def foo(): return 38") == None) + foo())
|
2014-03-31 18:02:22 +01:00
|
|
|
d = {}
|
|
|
|
exec("def bar(): return 40", d)
|
|
|
|
print(d["bar"]())
|
2020-03-23 02:26:08 +00:00
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
def fib2(n):
|
2020-03-23 02:26:08 +00:00
|
|
|
result = []
|
|
|
|
a, b = 0, 1
|
|
|
|
while a < n:
|
|
|
|
result.append(a)
|
|
|
|
a, b = b, a + b
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
print(fib2(100)[-2] - 14)
|
|
|
|
Answer = {}
|
|
|
|
Answer["ForAll"] = 42
|
2014-03-31 18:02:22 +01:00
|
|
|
print(Answer["ForAll"])
|
|
|
|
i = 43
|
2020-03-23 02:26:08 +00:00
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
def f(i=i):
|
|
|
|
print(i)
|
2020-03-23 02:26:08 +00:00
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
i = 44
|
|
|
|
f()
|
|
|
|
print(i)
|
|
|
|
while True:
|
2020-03-23 02:26:08 +00:00
|
|
|
try:
|
|
|
|
if None != True:
|
|
|
|
print(45)
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
print(0)
|
|
|
|
except:
|
|
|
|
print(0)
|
2014-03-31 18:02:22 +01:00
|
|
|
print(46)
|
2020-03-23 02:26:08 +00:00
|
|
|
print(46 + 1)
|
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
def u(p):
|
2020-03-23 02:26:08 +00:00
|
|
|
if p > 3:
|
|
|
|
return 3 * p
|
|
|
|
else:
|
|
|
|
return u(2 * p) - 3 * u(p)
|
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
print(u(16))
|
2020-03-23 02:26:08 +00:00
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
def u49():
|
2020-03-23 02:26:08 +00:00
|
|
|
return 49
|
|
|
|
|
|
|
|
|
2014-03-31 18:02:22 +01:00
|
|
|
print(u49())
|