Q. What does each of the following expressions evaluate to? Suppose that T is the tuple
("These", ("are", "a", "few", "words"), "that", "we", "will", "use")
(a)
T[1][0: : 2]
(b)
"a" in T [1] [ 0 ]
(c)
T [ : 1 ] + T[ 1 ]
(d)
T[ 2 : : 2 ]
(e)
T[2][2] in T[1]
Answer =
Output are follow:-
(a)
>>> T[1][0: : 2]
('are', 'few')
(b)
>>> "a" in T [1] [ 0 ]
True
(c)
>>> T [ : 1 ] + T[ 1 ]
('These', 'are', 'a', 'few', 'words')
(d)
>>> T[ 2 : : 2 ]
('that', 'will')
(e)
>>> T[2][2] in T[1]
True
>>>
In c, it should produce an error due to addends of different types, please correct
ReplyDeleteNo, it is correct please try it your idle python.
Deletec is wrong
ReplyDeleteNo, you are wrong please it in your idle python.
Deleteits correct
DeleteThank you
ReplyDeleteWelcome : )
Deleteyour answer of a and c is wrong because in a I was run so output is [''are'',''few''] it is in list and in c it gives error because we never concatenate (+) list and tuple
ReplyDeleteYou are wrong question is for tuple.
Deletepath wala you guys are wrong
Deletec is wrong i tried in idle ok
ReplyDeletePlease copy as it is then run it again.
DeleteI have uploaded proof
Deletec is correct
ReplyDeleteYes : )
DeleteThanx😊
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )