t = (1, 2, [3, 4])
d = {}
try:
d[t] = "success"
print(d[t])
except TypeError:
print("TypeError")
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Варианты ответа:
Anonymous Quiz
21%
{'a': 1, 'b': 2, 'c': 4}
55%
{'a': 1, 'b': 3, 'c': 4}
25%
TypeError
Please open Telegram to view this post
VIEW IN TELEGRAM
funcs = []
for i in range(3):
funcs.append(lambda x=i: x)
print([f() for f in funcs])
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
d = {'a': 1, 'b': 2, 'c': 3}
try:
for k in d:
del d[k]
print(len(d))
except RuntimeError:
print("RuntimeError")#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
class A:
def __init__(self):
self.__x = 1
def get_x(self):
return self.__x
class B(A):
def __init__(self):
super().__init__()
self.__x = 2
b = B()
print(b.get_x())
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
def f(x, y, z):
return x + y + z
d1 = {'x': 1, 'y': 2}
d2 = {'y': 3, 'z': 4}
try:
print(f(**d1, **d2))
except TypeError:
print("TypeError")
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
def add_item(num, lst=[]):
lst.append(num)
return lst
add_item(1)
print(add_item(2))
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
class MockObject:
def __new__(cls):
return 42
def __init__(self):
print("Init")
obj = MockObject()
print(obj)
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM