CBSE Class 12 Computer Science Question 8 of 42

Solved 2024 Sample Question Paper CBSE Class 12 Computer Science (083) — Question 8

Back to all questions
8
Question

Question 8

Consider the statements given below and then choose the correct output from the given options:

pride = "#G20 Presidency"
print(pride[-2:2:-2])
  1. ndsr
  2. ceieP0
  3. ceieP
  4. yndsr
Answer

ceieP0

Reason — The code assigns the string "#G20 Presidency" to the variable pride. The slicing operation pride[-2:2:-2] starts from the second last character ("y"), which is at index -2, moves backward by 2 characters at a time due to the step value of -2, and stops before reaching the third character ("G"), which is at index 2. Hence, the output will be 'ceieP0'.