wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python String Slicing

Total questions: 8

Worksheet time: 4mins

Name
Class
Date
1.

What will be the output of above Python code?

str1="6/4"

print("str1")

a)

1

b)

6/4

c)

1.5

d)

str1

2.

Which of the following will result in an error?

a)

print(str1[2])

b)

str1[1]="x"

c)

print(str1[0:9])

3.

What will be the output of below Python code?

str1="Information"

print(str1[2:8])

a)

format

b)

formatio

c)

orma

d)

ormat

4.

What will be the output of the code given below?

# Code snippet starts

org = ‘QuizOrbit’

print(org[-1:-6:-1])

# Code snippet ends

a)

tibrO

b)

Orbit

c)

Quiz

d)

QuizOrbit

5.

Find the output of the code given below?

# Code snippet starts

org = ‘QuizOrbit’

 print(org[::-1])

 # Code snippet ends

a)

tibrOziuQ

b)

QuizOrbit

c)

OrbitQuiz

6.

What is the output of below code:

s=’cppbuzz chicago’

print(s[3:5])

a)

buzzc

b)

pbuzz

c)

bu

7.

A string is an _______ data type.

a)

Mutable

b)

Immutable

8.

What is the index of the last character in a string?

a)

0

b)

-1

c)

1