wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python String Methods Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is the result of the following string concatenation in Python: "Hello" + " " + "World"?

a)

"HelloWorld"

b)

"Hello World"

c)

"Hello World"

d)

"HelloWorld "

2.

Which of the following operators is used for string concatenation in Python?

a)

*

b)

+

c)

-

d)

/

3.

What will be the output of the following code: print("Python" + "Programming")?

a)

Python Programming

b)

PythonProgramming

c)

Python+Programming

d)

Python Programming

4.

How can you concatenate the strings "Data" and "Science" with a space in between?

a)

"Data" + "Science"

b)

"Data" + " " + "Science"

c)

"Data" * "Science"

d)

"Data" - "Science"

5.

What is the result of slicing the string "HelloWorld" with [:5]?

a)

"Hello"

b)

"World"

c)

"HelloWorld"

d)

"oWorld"

6.

If s = "PythonProgramming", what does s[6:12] return?

a)

"Python"

b)

"Program"

c)

"Progra"

d)

"onProg"

7.

What will be the output of the following code: s = "abcdef"; print(s[2:5])?

a)

"abc"

b)

"bcd"

c)

"cde"

d)

"cdef"

8.

How can you extract the substring "World" from the string "HelloWorld"?

a)

s[5:]

b)

s[6:]

c)

s[5:10]

d)

s[6:11]

9.

What is the result of slicing the string "DataScience" with [-7:]?

a)

"Science"

b)

"Data"

c)

"taScien"

d)

"aScience"

10.

If s = "Business", what does s[:4] return?

a)

"Busi"

b)

"ness"

c)

"Busin"

d)

"Busi"

11.

What will be the output of the following code: s = "abcdef"; print(s[-3:])?

a)

"abc"

b)

"def"

c)

"cde"

d)

"bcd"

12.

How can you concatenate the strings "Grade" and "10" without any space?

a)

"Grade" + "10"

b)

"Grade" + " " + "10"

c)

"Grade" * "10"

d)

"Grade" - "10"

13.

What is the result of slicing the string "Programming" with [3:8]?

a)

"Progr"

b)

"gramm"

c)

"gram"

d)

"rammi"

14.

If s = "Economics", what does s[1:5] return?

a)

"Econ"

b)

"cono"

c)

"cono"

d)

"cono"

15.

What will be the output of the following code: s = "abcdef"; print(s[1:4])?

a)

"abc"

b)

"bcd"

c)

"cde"

d)

"def"