PythonByteSize
  • Home
  • Detailed Videos
  • 1-Minute Videos
  • Exercises
  • Donate
  • Computing Topics
  • Mathematics
  • Educators
  • Contact
  • About

Exercise 4.8. (Pythons id() function and names)


1. Ensure you have viewed the video (associated with this exercise) at this link >> 

2. The following program:

y = 5
print(y)
print(id(y))

gives the following output:

5
140711163713312
>>>


​Armed with this information complete the model representation (shown below) for the above program.
Picture

3. Consider the following computer program:

p = 53
r = 61
print(p)
print(r)
print(id(p))
print(id(r))


its output is shown below:

53
61
140711163714848
140711163715104
>>>


Through consideration of the information above draw a model in a style like the one shown for question 2 above.

4. Consider the following computer program:

a = 75
b = 75
print(a)
print(b)
print(id(a))
print(id(b))


its output is shown below:

75
75
140711163715552
140711163715552
>>>


Through consideration of the information above draw a model in a style like the one shown for question 2 above. (Hint: take note of the id of the variables a and b)

5. Consider the following computer program:

w = 21
x = w
print(w)
print(w)
print(id(x))
print(id(x))

its output is shown below:

21
21
140711163713824
140711163713824
>>>


Through consideration of the information above draw a model in a style like the one shown for question 2 above.

END    

Please consider donating to help with the costs incurred in developing this website.             Donate >>