Assuming A = [1, 2, 3,5,7,8,9] what is
the output of
:>>> A[3:0:-1]
Answers
Answered by
0
Answer:
The output will be:
_______________
5
3
2
_______________
Explanation:
Mark the indices of the elements as,
A[0]=1,
A[1]=2,
A[2]=3,
A[3]=5,
A[4]=7,
A[5]=8,
A[6]=9,
Now, the slicing method you used had -1 as skipping number, which means the list will be read backwards.
The initial number is 3, which means it will be read from 3.
And the final number is 0 which mean the list will be read till one element before 0 which is 1 here.
Summarizing it , the numbers you should except should begin at 3rd index, moving backwards just before index 0 and so the mentioned output would be printed as a result.
Here's one verification code (image).
Attachments:
Similar questions
Math,
2 months ago
Science,
5 months ago
Computer Science,
5 months ago
English,
11 months ago
History,
11 months ago