Q. Consider the following code: what is the value of ‘a’ at the end?
a = [1, 2, 3]
a [2] = 0
a [a [ 2 ] ] = 5
a [1:2] = []
Answer =
Value of ‘a’ at the end is:
[5, 0]
Output
a = [1, 2, 3] -----------> a = [1, 2, 3]
a [2] = 0 -----------> a = [1, 2, 0]
a [a [ 2 ] ] = 5 -----------> a = [5, 2, 0]
a [1:2] = [] -----------> a = [5, 0]
How the list [5,0] came?
ReplyDeletea [a [ 2 ] ] = 5 =>[5,2,0]
How 5 came?
You have not see a [1:2] = [], this statement delete value of a at index number 1 . so at last our a is [5,0] .
Deleteloosyu kyesefd
ReplyDeleteCan you explain it plz
ReplyDeleteOk, I Have written output in right side of script.
DeleteCan you please send me the practical of of data handling
ReplyDeleteI have uploaded on website.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )