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)
>>>
Ans
ReplyDelete2
2
False
3
3
55
(1,(2,),1)
You are wrong Please check again.
Deleteit 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
DeleteThe question is wrong, please check the question.
ReplyDeleteTell me wrong part. If it is wrong then i will correct it.
DeleteWhy will the len of first be 2?
ReplyDeleteBecause ther is only 2 element in tuple that is 1 and (2, (3, (4,)))
DeleteWhy last one is (1,(2,),1)?
ReplyDeletez[z[ 2 ] ]
Deletez [ 1 ]
(1, (2,), 1)
In line 8 the following is the question: print y[2] +50
ReplyDeleteTell me your problem.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )