Test Index

Python Revision Tour Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 70 of 102
Marks: +1, -0
Consider the statements given below and then choose the correct output from the given options :
Game="World Cup 2023"
print(Game[-6::-1])
[CBSE 2024 Compartment]
Solution:  
Concept:
In s[start::-1] the step -1 walks the string backwards from index start to the beginning of the string.
Explanation:
Game = "World Cup 2023" has 14 characters (index 0 to 13).
Index012345678910111213
CharWorld(space)Cup(space)2023
Negative-14-13-12-11-10-9-8-7-6-5-4-3-2-1
Index -6 is 'p' (index 8). Reading backwards from 'p' to 'W':
puC dlroW
Answer:
Option C (puC dlroW)
© examsnet.com
Advertisements
Go to Question: