Posts All about Python (1)
Post
Cancel

All about Python (1)

Python is an object-oriented programming language, and in Python everything is an object

Variable

Variable is for naming an object

1
2
3
4
a, b = 3, 2
print(a, b)
a, b = b, a
print(a, b)
1
2
3, 2
2, 3

id(): python object’s real memory location

1
2
3
4
a = 5
print(id(a))
b = 5
print(id(b)
1
2
1946757065136
1946757065136

b does not made new object
A object made by a = 5 command and b = 5 command just renamed A object.

~~call by value reference on 2-5 ~~

This post is licensed under CC BY 4.0 by the author.