Python Quiz # 3 What is the output of this code snippet? A) ['abc', 'y', 'z'] B) [1, 2, 3] C) ['x', 'y', 'z'] D) All of the above Answer for Quiz # 2 in the thread ๐Ÿงต๐Ÿ‘‡

python_spaces's tweet image. Python Quiz # 3

What is the output of this code snippet?

A) ['abc', 'y', 'z']
B) [1, 2, 3]
C) ['x', 'y', 'z']
D) All of the above

Answer for Quiz # 2 in the thread ๐Ÿงต๐Ÿ‘‡

If you have missed previous quizzes in this series, don't worry! You can follow this link and go back to quiz 1.


That's a wrap! I hope you learnt something new today. Follow me @python_spaces for more such content. Like and RT the first tweet to share with your friends. Cheers ๐ŸŽ‰

์ด ํŠธ์œ—์€ ๋” ์ด์ƒ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

Hope it's useful. I am going to share more quizzes in this series.


C) ['x', 'y', 'z'] For the benefit of those that wish to understand the result. ๐Ÿ‘‡

SamuelOsondu_Py's tweet image. C) ['x', 'y', 'z']

For the benefit of those that wish to understand the result.
๐Ÿ‘‡

Ans is C) [โ€˜xโ€™, โ€˜yโ€™, โ€˜zโ€™] Explain: copy() function performs shallow copy which means after copying it i.e., value of b to d value refer to different memory location instead of location of variable b. So if we check the value of b it would be [โ€˜xโ€™, โ€˜yโ€™, โ€˜zโ€™]

anurag_nakhate's tweet image. Ans is C) [โ€˜xโ€™, โ€˜yโ€™, โ€˜zโ€™]

Explain:
copy() function performs shallow copy which means after copying it i.e., value of b to d value refer to different memory location instead of location of variable b.
So if we check the value of b it would be [โ€˜xโ€™, โ€˜yโ€™, โ€˜zโ€™]

[x,y,z]... No operation is done on b and hence the result will be untouched. Thanks.


C) ['x', 'y', 'z']


C. Because b doesn't point to the data that d points


The answer is C) [โ€˜xโ€™, โ€˜yโ€™, โ€˜zโ€™]


The code ran without error but no out on the terminal


Option C ['x', 'y', 'z']


United States ํŠธ๋ Œ๋“œ
Loading...

Something went wrong.


Something went wrong.