Embed presentation
Download to read offline
![1. How many list objects are created by the code below?
>>> x = [5]
>>> y = x
>>> z = y+x
>>> x.append(10)
2. How many str objects are created by the code below?
>>> x = 'ab'
>>> y = x
>>> z = x
>>> z += 'c'
3. How many objects are created by the code below?
>>> lst_one = [1]
>>> lst_two = [2]
>>> lst_three = [lst_one, lst_two]
Solution
1: 15 list object are created x.append(10) before that x had 5 list objects
2: three string objects are created x = ab , y =ab and z = abc](https://image.slidesharecdn.com/1-230709135546-26f07645/85/1-How-many-list-objects-are-created-by-the-code-below-x-5-pdf-1-320.jpg)
The document addresses object creation in Python code snippets, detailing how many list and string objects are created. In the first example, it explains that 15 list objects result from the operations performed on the list. The second example states that three string objects are created through the manipulation of string values.
![1. How many list objects are created by the code below?
>>> x = [5]
>>> y = x
>>> z = y+x
>>> x.append(10)
2. How many str objects are created by the code below?
>>> x = 'ab'
>>> y = x
>>> z = x
>>> z += 'c'
3. How many objects are created by the code below?
>>> lst_one = [1]
>>> lst_two = [2]
>>> lst_three = [lst_one, lst_two]
Solution
1: 15 list object are created x.append(10) before that x had 5 list objects
2: three string objects are created x = ab , y =ab and z = abc](https://image.slidesharecdn.com/1-230709135546-26f07645/85/1-How-many-list-objects-are-created-by-the-code-below-x-5-pdf-1-320.jpg)