Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Strings

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

A: Strings can be changed during execution

B. Strings can be enclosed within single, double or even triple quotes

C. Strings are immutable

a)

A,B & C are True

b)

A,B are True but C is False

c)

B, C are True but A is False

d)

A,C are True but B is False

2.

Find the output of the following code:

>>>str1='Save Soil'

>>>str1.isalnum( )

a)

Save Soil

b)

True

c)

False

3.

Identify the string membership operators of Python

a)

in, not in

b)

like, not like

c)

as, not as

d)

between, not between

4.

Which is the powerful function used for formatting strings?

a)

chr( )

b)

format( )

c)

title( )

d)

capitalize( )

5.

The title( ) function

a)

assigns title

b)

returns the title of the file

c)

returns string in title case

6.

Predict the output:

>>>str1="Rajathi Raja"

>>>print(str1.count('Raja'))

a)

1

b)

2

c)

Error

d)

Raja

7.

Match the following:

1. \n A) Carriage return

2. \v B) BackSpace

3. \b C) new line

4. \r D) Vertical tab

a)

1-C, 2-D, 3-B, 4-A

b)

1-A, 2-C, 3-B, 4-D

c)

1-C, 2-D, 3-A, 4-B

d)

1-C, 2-A, 3-B, 4-D

8.

Predict the output:

>>>saint="Thiruvalluvar"

>>>print(saint[5:])

a)

valluvar

b)

Thiruvalluvar

c)

uvalluvar

d)

Thiru

9.

MATCH THE FOLLOWING:

1. concatenation A) +=

2. Append B) [ ]

3. String Slicing C) *

4. Repeating D) +

a)

1-B. 2-A, 3-C, 4-D

b)

1-D. 2-A, 3-B, 4-C

c)

1-A,2-B,3-C,4-D

d)

1-A,2-D,3-C,4-B

10.

s="welcome"

print( s. center (15,'*'))

a)

***welcome***

b)

****welcome****

c)

****welcome***

d)

undefine function center