Dynamic typing Flashcards

1
Q

What is dynamic typing?

A

Types are determined automatically at runtime, not in response to declarations in code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you test if two variables contain the same values?

A

a == b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you test if two variables reference the same objects?

A

a is b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you tell how many references there are to an object?

A

import sys

sys.getrefcount(object)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly