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]


7 Comments

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

  1. How the list [5,0] came?
    a [a [ 2 ] ] = 5 =>[5,2,0]
    How 5 came?

    ReplyDelete
    Replies
    1. 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] .

      Delete
  2. loosyu kyesefd

    ReplyDelete
  3. Replies
    1. Ok, I Have written output in right side of script.

      Delete
  4. Can you please send me the practical of of data handling

    ReplyDelete

Post a Comment

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

Previous Post Next Post