Python Programming Training Certification
Flexible Hours
100 Assignments
Instructor Led online Training
50 LMS Access
24X7 Support
100% Skill Level
Enquire Now
Course Overview
Python id() Function
Python id() function returns an identity of an object. This is an integer which is guaranteed to be unique. This function takes an argument an object and returns a unique integer number which represents identity. Two objects with non-overlapping lifetimes may have the same id() value.
Signature
- id (object)
Parameters
object : It is an object of which id is to be returned.
Return
It returns a unique integer number.
Let’s see some examples of id() function to understand it’s functionality.
Python id() Function Example 1
-
# Python id() function example
# Calling function
val = id(“Javatpoint”) # string object
val2 = id(1200) # integer object
val3 = id([25,336,95,236,92,3225]) # List object
# Displaying result
print(val)
print(val2)
print(val3)
Output:
-
139963782059696
139963805666864
139963781994504
Python id() Function Example 2
-
# Python id() function example
class Student:
def __init__(self, id, name):
self.id = id
self.name = namestudent = Student(101,”Mohan”)
print(student.id)
print(student.name)
# Calling function
val = id(student) # student class object
# Displaying result
print(“Object id:”,val)
Output:
-
101
Mohan
Object id: 140157155861392
Python id() Function Example 3
-
# Python id() function example
l1 = [1,2,3,4]
l2 = [1,2,3,4]
l3 = [3,5,6,7]
# Calling function
id1 = id(l1)
id2 = id(l2)
id3 = id(l3)
# Displaying result
print((l1==l2),(l1==l3))
# Objects with the same values can have different ids
print((id1==id2),(id1==id3))
# l1 and l2 returns True, while id1 and id2 returns False
Output:
-
True False
False False
Candidate’s Journey During Our Training Program
Expert’s Advice & Selection of Module
Choosing the right type of module for the training is half the battle & Our Team of experts will help & guide you.
Get Trained
Get Trained & Learn End to End Implementation from our Expert Trainer who are working on the same domain.
Work on Projects
We Do make our student’s work on multiple case studies , scenario based tasks & projects in order to provide real-time exposure to them.
Placements
We have a dedicated placement cell in order to provide placement assistance & relevant interviews to our candididates till selection
Placement Partner