Q. Predict the output:

 

x = (1, (2, (3, (4,))))

print (len(x))

print( x[1][0])

print(2 in x)

y = (1, (2, (3,), 4), 5)

print len((y))

print(len(y[1])

print( y[2] = 50)

z = (2, (1, (2,), 1), 1)

print (z[z[z[0]]])

 

Answer = 


It will give an error.

 

If correct code is :-



x = (1, (2, (3, (4,))))
print (len(x))
print( x[1][0])
print(2 in x)
y = (1, (2, (3,), 4), 5)
print (len((y)))
print(len( y[1] ) )
print( y[2] ==50 )
z = (2, (1, (2,), 1), 1)
print (z[z[z[0]]])

 

Then Output is

2
2
False
3
3
False
(1, (2,), 1)
>>> 

11 Comments

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

  1. Ans
    2
    2
    False
    3
    3
    55
    (1,(2,),1)

    ReplyDelete
    Replies
    1. You are wrong Please check again.

      Delete
    2. it is correct as the output is given as 55 not false please check from your side if there's any mistake , thank you , this is a different person replying not the one who has given this answer

      Delete
  2. The question is wrong, please check the question.

    ReplyDelete
    Replies
    1. Tell me wrong part. If it is wrong then i will correct it.

      Delete
  3. Why will the len of first be 2?

    ReplyDelete
    Replies
    1. Because ther is only 2 element in tuple that is 1 and (2, (3, (4,)))

      Delete
  4. Why last one is (1,(2,),1)?

    ReplyDelete
  5. In line 8 the following is the question: print y[2] +50

    ReplyDelete

Post a Comment

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

Previous Post Next Post