Foundations 0/223

Foundations

Python semantics

How Python binds names to objects: identity and equality, mutable values shared through aliases, argument passing, scope, default arguments, closures and hashing. Interviewers probe these with short snippets whose output looks obvious and is not.

0 / 59 solved

Questions

0/59 solved
Question Module Tags Difficulty Success
1. One Dict, Two Names Names & Identity
names-vs-objectsaliasing +2
Medium 68%
2. Mutate In Place, Rebind Elsewhere Names & Identity
mutation-vs-rebindingaliasing +1
Medium 46%
3. Equal Value, Different Object Names & Identity
is-vs-equalsidentity +1
Medium 68%
4. Passing Doesn't Mean Sharing Names & Identity
mutation-vs-rebindingaliasing +1
Medium 48%
5. What The Spec Actually Guarantees Names & Identity
is-vs-equalscpython-implementation-detail +1
Hard 32%
6. Same Address, Borrowed Later Names & Identity
ididentity +2
Hard 47%
7. The Shared Default Bucket Names & Identity
aliasingmutation-vs-rebinding +1
Hard 46%
8. Interning On Request Names & Identity
cpython-implementation-detailidentity +1
Hard 68%
9. Two 257s, One Object Names & Identity
cpython-implementation-detailidentity +1
Insane 60%
10. Mutating a Shared List Argument Function Arguments
argument-bindingmutation +1
Medium 91%
11. Mutation Versus Rebinding in One Call Chain Function Arguments
argument-bindingmutation +1
Medium 71%
12. Positional and Keyword Argument Conflict Function Arguments
positional-argumentskeyword-arguments +1
Medium 53%
13. Collecting Extra Positional Arguments Function Arguments
argstuple +1
Medium 46%
14. Keyword-Only Parameters After a Bare Star Function Arguments
keyword-onlyargument-binding +1
Medium 36%
15. Splitting Extra Positionals and Keywords Function Arguments
argskwargs +1
Hard 74%
16. Positional-Only and Keyword-Only Together Function Arguments
positional-onlykeyword-only +1
Hard 58%
17. Python's Argument-Passing Model Function Arguments
argument-bindingobject-reference +1
Hard 46%
18. Tuple Item Assignment Fails Mutability & Aliasing
mutabilitytuples +2
Medium 78%
19. A List Inside A Tuple Mutability & Aliasing
tuplesaliasing +2
Medium 63%
20. In-Place Mutation Versus Rebinding Mutability & Aliasing
augmented-assignmentmutation +2
Medium 39%
21. Unhashable List In A Tuple Key Mutability & Aliasing
hashabilityimmutability +2
Medium 63%
22. Three Ways To Shallow Copy Mutability & Aliasing
shallow-copyidentity +2
Medium 65%
23. New Object Or Same Object Mutability & Aliasing
shallow-copyaliasing +2
Hard 73%
24. Slicing A List Of Lists Mutability & Aliasing
slicingshallow-copy +1
Hard 58%
25. Deepcopy Isolates Nested Data Mutability & Aliasing
deep-copycopy-module +1
Hard 100%
26. Shallow Copy Stops At One Level Mutability & Aliasing
shallow-copydeep-copy +1
Insane 90%
27. LEGB Lookup Skips to Enclosing Scope & Namespaces
legbscope +1
Medium 90%
28. Global Statement Needed Only to Assign Scope & Namespaces
global-statementscope +1
Medium 56%
29. Nonlocal Counter Closures Scope & Namespaces
nonlocalclosures +1
Medium 50%
30. Assignment Anywhere Makes It Local Scope & Namespaces
unboundlocalerrorscope +1
Medium 43%
31. Shadowing a Builtin Two Ways Scope & Namespaces
shadowingbuiltins +2
Hard 44%
32. Comprehension Variable Versus For Loop Variable Scope & Namespaces
comprehension-scopefor-loop +1
Hard 58%
33. Scope Rules Select All That Apply Scope & Namespaces
global-statementnonlocal +2
Hard 19%
34. Walrus Leaks, Loop Variable Does Not Scope & Namespaces
walrus-operatorcomprehension-scope +1
Hard 70%
35. Walrus Target Lands in the Function, Not Global Scope & Namespaces
walrus-operatorcomprehension-scope +1
Hard 60%
36. Default Evaluated Once, At Definition Default Arguments
default-argumentsdefinition-time +1
Medium 58%
37. The Classic Mutable Default Trap Default Arguments
mutable-defaultaliasing +1
Medium 100%
38. The None-Sentinel Fix Default Arguments
none-sentinelmutable-default +1
Medium 55%
39. What __defaults__ Actually Holds Default Arguments
dunder-defaultsmutable-default +1
Medium 36%
40. Mutating vs Rebinding the Default Default Arguments
mutable-defaultmutation-vs-rebinding +1
Hard 86%
41. Reading __defaults__ After Mutation Default Arguments
dunder-defaultsmutable-default +1
Hard 100%
42. Rebinding the Name, Not the Default Default Arguments
definition-timealiasing +2
Hard 50%
43. Freezing the Loop Variable Default Arguments
definition-timeclosures +2
Hard 100%
44. Closures Keep Their Enclosing Variables Closures & Late Binding
closuresfree-variables
Medium 100%
45. Read Time, Not Definition Time Closures & Late Binding
closureslate-binding +1
Medium 50%
46. The Loop Variable Cell Closures & Late Binding
closureslate-binding +1
Medium 29%
47. Mutating an Outer Local Needs nonlocal Closures & Late Binding
nonlocalclosures +1
Medium —
48. Fixing Late Binding With a Default Argument Closures & Late Binding
closureslate-binding +1
Hard 83%
49. Mutating a List Doesn't Need nonlocal, Rebinding Does Closures & Late Binding
nonlocalclosures +1
Hard —
50. A Fresh Cell Per Call Is Not the Loop Bug Closures & Late Binding
closureslate-binding +1
Hard 71%
51. Shared Cells Across Sibling Closures Closures & Late Binding
nonlocalclosures +1
Hard 57%
52. Membership Needs A Hash Containers & Hashing
containersmembership +1
Medium 71%
53. Which Order Is A Promise Containers & Hashing
dictset +2
Medium 100%
54. The Silent Hash Override Containers & Hashing
hashingequality +1
Medium 67%
55. What A Set Will Accept Containers & Hashing
hashingset +2
Medium 50%
56. Hash Across The Numeric Tower Containers & Hashing
hashingequality +1
Medium 80%
57. Equal But Unfindable Containers & Hashing
hashingequality +1
Hard —
58. Which Keys Survive Containers & Hashing
hashingdict-keys +2
Hard 80%
59. Freeze It To Use It As A Key Containers & Hashing
hashingmutability +2
Hard 57%