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

Exercise 4.7. (Pythons id() function)


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

2. What is the main purpose of an address register?

3. The contents of an address register are transferred via which bus to select a location?

4. In your own words describe what is meant by contiguous memory locations.

5. With reference to all programming languages what is your understanding of a pointer?

6. The following program:

x = 91
print(x)
print(type(x))
print(id(x))


gives this output:

91
<class 'int'>
140711163713440

>>>


In your own words describe exactly what is being displayed on each line of the output.

7. The following program:
​

x = 66
print(id(x))


gives the following output:

140711163715264
>>> 

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

8. Consider the following program:

x = 75
y = 43
print(x)
print(y)
print(id(x))
print(id(y))


The output from the program is shown below:
​

75
43
140711163715552
140711163714528
>>>


Armed with the information above what are the value and unique identifier for the variables x and y?

9. Consider the following program:

x = 17
y = 17
print(x)
print(y)
print(id(x))
print(id(y))


The output from the program is shown below:
​

17
17
140711163713696
140711163713696
>>>


For the program above explain why the unique identifier for the variables x and y are not unique.

END    Next Exercise >>

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