Robotics & Artificial Intelligence
What does the following code output?
string = "Hello World"
print(string[1:5])
- "Hell"
- "ello"
- "World"
- "Hello"
Python String Manipulation
1 Like
Answer
"ello"
Reason — In Python, string slicing returns characters from the starting index up to the ending index minus one. Therefore, string[1:5] extracts the characters at index positions 1, 2, 3, and 4, which are e, l, l, and o, and hence the output is "ello".
Answered By
3 Likes
Related Questions
What are the 4 Ws used for understanding a problem in AI project scoping?
- Who, What, When, Where
- Why, When, Where, What
- Who, What, Where, Why
- Who, Where, When, Why
What type of graph is shown in the image?

- Line graph
- Bar graph
- Pie chart
- Scatter plot
The full form of IDLE is:
- Integrated Development and Language Environment.
- Integrated Development and Learning Environment.
- Inline Development and Learning Environment.
- Inside Development and Language Environment.
Which operation can be performed on both lists and tuples?
- Append elements
- Insert elements
- Access elements
- Delete elements