Computer Science, asked by hem01011971, 8 months ago

What will be the output of the following Python statement? x="abcd" print(x[2:])

Answers

Answered by premlatag976
3

Answer:

the output will be of this phython statement is

'c'

Answered by sarahssynergy
0

Output of the statement will be cd.

Explanation:

  1. in python programing language a command of type A[1:] means data stored at the index 1 to end or last index of the x.
  2. for example , A=[l, m, n, o, p, q] then A[1:]= [m, n, o, p, q]
  3. here, x=\ "abcd" is stored as ,                                                                                        index\ 0\ 1\ 2\ 3\\data\ \ a\ b\ c\ d                                      
  4. hence, the statement print(x[2:]) will print the values starting at index 2 till the value at last index (that is 3)
  5. Therefore, final output is cd

Similar questions