Dynamic typing Flashcards
1
Q
What is dynamic typing?
A
Types are determined automatically at runtime, not in response to declarations in code.
2
Q
What is a shared reference?
A
When two variables point to the same underlying object. For example:
a = 3 b = a
A and b point to the same object, 3.
3
Q
If you have a shared reference and change one of them, what happens to the other?
A
Nothing. They now point to different objects.
4
Q
How do you test if two variables contain the same values?
A
a == b
5
Q
How do you test if two variables reference the same objects?
A
a is b
6
Q
How do you tell how many references there are to an object?
A
import sys
sys.getrefcount(object)