Q. What is the output of following code fragments?

(i)

def increment(n):

    n. append([4])

    return n

L = [1, 2, 3]

M = increment(L)

print(L, M)


(ii)

def increment(n):

    n. append([49])

    return n[0], n[1], n[2], n[3]

L = [23, 35, 47]

mi, m2, m3, m4 = increment (L)

print(L)

print(mi, m2, m3, m4)

print(L[3] == m4)


Answer :-


(i)

Output:-

[1, 2, 3, [4]] [1, 2, 3, [4]]


(ii)
Output: -
[23, 35, 47, [49]]
23 35 47 [49]
True

>>>


10 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. please check first output l should be equal to[1,2,3]

    ReplyDelete
    Replies
    1. Output are correct . Please copy the script and paste in your idle python then run it 😊

      Delete
    2. That is, if the function was not called.

      Delete
  2. Why at last ut says true??

    ReplyDelete
  3. Plss provide a video solution for this question

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post