Computer Science
Following set of commands is executed in shell, what will be the output?
>>>str = "hello"
>>>str[:2]
>>>
- he
- lo
- olleh
- hello
Python String Manipulation
5 Likes
Answer
he
Reason — str[:2]
here slicing operation begins from index 0 and ends at index 1. Hence the output will be 'he'.
Answered By
1 Like
Related Questions
The operator …………… tells if an element is present in a sequence or not.
- exists
- in
- into
- inside
The keys of a dictionary must be of …………… types.
- integer
- mutable
- immutable
- any of these
What data type is the object below ?
L = [1, 23, 'hello', 1]- list
- dictionary
- array
- tuple
What data type is the object below ?
L = 1, 23, 'hello', 1- list
- dictionary
- array
- tuple