PYTHON_JOB_INTERVIEW Telegram 1072
Что выведет этот код на Python?


x = [1, 2, 3]
y = x
x += [4]

print(x)
print(y)


🔢 Варианты ответа:

A)

[1, 2, 3]


B)

[1, 2, 3, 4]


C)

[1, 2, 3, 4]


D)

[1, 2, 3]


Правильный ответ: B

💡 Почему?
-
x = [1, 2, 3] и y = x — ссылка на один и тот же список.
-
x += [4] модифицирует список на месте.
- Поэтому
y тоже видит изменение.
🧠 Подвох — в
+=, который работает не как x = x + [...].
👍13❤‍🔥43



tgoop.com/python_job_interview/1072
Create:
Last Update:

Что выведет этот код на Python?


x = [1, 2, 3]
y = x
x += [4]

print(x)
print(y)


🔢 Варианты ответа:

A)

[1, 2, 3]


B)

[1, 2, 3, 4]


C)

[1, 2, 3, 4]


D)

[1, 2, 3]


Правильный ответ: B

💡 Почему?
-
x = [1, 2, 3] и y = x — ссылка на один и тот же список.
-
x += [4] модифицирует список на месте.
- Поэтому
y тоже видит изменение.
🧠 Подвох — в
+=, который работает не как x = x + [...].

BY Python вопросы с собеседований


Share with your friend now:
tgoop.com/python_job_interview/1072

View MORE
Open in Telegram


Telegram News

Date: |

Deputy District Judge Peter Hui sentenced computer technician Ng Man-ho on Thursday, a month after the 27-year-old, who ran a Telegram group called SUCK Channel, was found guilty of seven charges of conspiring to incite others to commit illegal acts during the 2019 extradition bill protests and subsequent months. With the sharp downturn in the crypto market, yelling has become a coping mechanism for many crypto traders. This screaming therapy became popular after the surge of Goblintown Ethereum NFTs at the end of May or early June. Here, holders made incoherent groaning sounds in late-night Twitter spaces. They also role-played as urine-loving Goblin creatures. Telegram channels fall into two types: Concise How to create a business channel on Telegram? (Tutorial)
from us


Telegram Python вопросы с собеседований
FROM American