🧩 Сложная задача по Python для опытных разработчиков
Что выведет следующий код?
def func(a, L=[]): L.append(a) return L
print(func(1)) print(func(2)) print(func(3))
Варианты ответа: A)
[2] [3]
B)
[1, 2] [1, 2, 3]
C)
[1] [1]
D)
[2] [3]
---
✅ Правильный ответ: B
Почему: Списки по умолчанию (L=[]) в Python инициализируются один раз при определении функции, а не каждый раз при вызове. Поэтому изменения сохраняются между вызовами func. Это классическая "ловушка" со значениями по умолчанию!
🧩 Сложная задача по Python для опытных разработчиков
Что выведет следующий код?
def func(a, L=[]): L.append(a) return L
print(func(1)) print(func(2)) print(func(3))
Варианты ответа: A)
[2] [3]
B)
[1, 2] [1, 2, 3]
C)
[1] [1]
D)
[2] [3]
---
✅ Правильный ответ: B
Почему: Списки по умолчанию (L=[]) в Python инициализируются один раз при определении функции, а не каждый раз при вызове. Поэтому изменения сохраняются между вызовами func. Это классическая "ловушка" со значениями по умолчанию!
A leaked Telegram discussion by 50 so-called crypto influencers has exposed the extraordinary steps they take in order to profit on the back off unsuspecting defi investors. According to a leaked screenshot of the chat, an elaborate plan to defraud defi investors using the worthless “$Few” tokens had been hatched. $Few tokens would be airdropped to some of the influencers who in turn promoted these to unsuspecting followers on Twitter.
Start with a fresh view of investing strategy. The combination of risks and fads this quarter looks to be topping. That means the future is ready to move in.Likely, there will not be a wholesale shift. Company actions will aim to benefit from economic growth, inflationary pressures and a return of market-determined interest rates. In turn, all of that should drive the stock market and investment returns higher.