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

1. How many list objects are created by the code below x = [5].pdf

  • 1.
    1. How manylist 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