NEW
Font size
WorksheetsPython String Slicing
Total questions: 8
Worksheet time: 4mins
What will be the output of above Python code?
str1="6/4"
print("str1")
1
6/4
1.5
str1
Which of the following will result in an error?
print(str1[2])
str1[1]="x"
print(str1[0:9])
What will be the output of below Python code?
str1="Information"
print(str1[2:8])
format
formatio
orma
ormat
What will be the output of the code given below?
# Code snippet starts
org = ‘QuizOrbit’
print(org[-1:-6:-1])
# Code snippet ends
tibrO
Orbit
Quiz
QuizOrbit
Find the output of the code given below?
# Code snippet starts
org = ‘QuizOrbit’
print(org[::-1])
# Code snippet ends
tibrOziuQ
QuizOrbit
OrbitQuiz
What is the output of below code:
s=’cppbuzz chicago’
print(s[3:5])
buzzc
pbuzz
bu
A string is an _______ data type.
Mutable
Immutable
What is the index of the last character in a string?
0
-1
1
