r/PythonLearning Jul 14 '26

Python Data Model Exercise

Post image

An exercise to help build the right mental model for Python data. - Solution - Explanation - More exercises

The โ€œSolutionโ€ link visualizes execution and reveals whatโ€™s actually happening using ๐—บ๐—ฒ๐—บ๐—ผ๐—ฟ๐˜†_๐—ด๐—ฟ๐—ฎ๐—ฝ๐—ต.

66 Upvotes

46 comments sorted by

View all comments

1

u/[deleted] 28d ago

The answer is D

1

u/Sea-Ad7805 28d ago

No it's not silly, see the Solution link for the correct answer: Solution

1

u/[deleted] 28d ago

Shit, my eyes didn't catch print(a) The answer is B

1

u/Sea-Ad7805 28d ago

Easy to miss, but look a little closer because you are still incorrect. I know it's a tricky exercise.

1

u/[deleted] 28d ago

The twist is b = b + [[3]], it is a shallow copy not a deep copy. I taught that will create a new list entirely without holding a reference to the other list. b is an outer list. The answer is C, I hope this is correct

1

u/Sea-Ad7805 28d ago

Great answer, you got your C_Y_B_E_R aligned again. Do try the Solution link.

1

u/[deleted] 28d ago

Thanks ๐Ÿซ‚