In Python, the id()
function is used to return an object’s identity.
id(object)
object
: This represents the identity to be returned.This function returns an object’s identity.
# create a class with a propertyclass Person:name = "Maria"# create object of the classperson = Person()# get the idprint('Id:',id(person))# create a variablex = 10print('Id:',id(x))# create a listmy_list = [12, 3.5, "shot"]print('Id:',id(my_list))
Person
with a property named name
.person
.person
using id()
.x
and display its identity.my_list
and display its identity.