Can u explain this?

1 Like

Hello @sudhakarreddy1704 ,
We have recieved your query.
This was a really nice question which you have asked.

Give us a couple of minutes & we will reach out with the solution for your query

Zeba Kainat| TA- Edyoda


In Python list, tuple ,string ,float ,integer all are objects so in the above visualization we have to count how many number of objects are present in this x variable

1)In x we store a list inside that list there are 4 objects which are tuple, set, string and float->4 objects

2)A tuple consist of 3 integers so there are 3 objects inside a tuple (1,2,3) ->3 objects

3)A set consist of 4 integers {1,1,1,2} but the property of a set is to remove duplicates so finally we get {1,2}->2 objects

4)So till now our total is 9 objects but we have to calculate the list in which all this objects are stored that is ->1 object of list

5)So our total number of objects formed in memory are 4+3+2+1=10 objects

@sudhakarreddy1704 I hope now it is clear :slight_smile:

Kalyani Dudhekar |TA -Edyoda

1 Like