PythonByteSize
  • Home
  • Video Index
    • 1. The Basics
    • 2. Python Program Structures
    • 3. Python Operators
    • 4. Python Functions
    • 5. Introduction to Classes and Objects
    • 6. Python Strings
    • 7. User Defined Functions
    • 8. Classes and Objects
    • 9. Python Dictionaries
    • 10. Python tkinter
    • 11. Python Lists
    • 12. Python Namespaces
    • 13. Turtle Graphics
    • 14. Python Tips
    • 15. Complex Numbers
  • 1-Minute Videos
  • Exercise Index
    • 1. The Basics Exercises
    • 2. Python Program Structures Exercises
    • 3. Python Operators Exercises
    • 4. Python Functions 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 >>