Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python String Functions

Total questions: 12

Worksheet time: 9mins

Name
Class
Date
1.
What is a string?
a)
A type that represents sequences of characters.
b)
One of the values on which an operator operates.
c)
A type that represents whole numbers.
d)
A combination of variables, operators, and values that represents a single result value.
2.

How do we store a string with the value: string

a)

'string'

b)

"string"

c)

%string%

d)

#string#

3.

For strings, the symbol + means........................

a)

addition

b)

swap

c)

concatenation

d)

slicing

4.

What is the output of the following code?

str1='101'

x=int(str1)

z=x+400

print(z)

a)

101400

b)

x400

c)

501

d)

none of above

5.

What is the output of the following code?

fruit1="kiwi"

fruit2="strawberry"

print(len(fruit1))

print(len(fruit2))

a)

kiwi and strawberry

b)

4

10

c)

4 10

d)

410

6.

The index of a string begins with ...

a)

1

b)

0

c)

a

d)

-1

7.

What is the output of the following code?

X="BOnVoyage"

print X[0:5]

a)

BOnVoy

b)

BOnVo

c)

oyage

d)

bonvo

8.

What is the output of the following code?

x="BOnvoyage"

print(x[4: ])

a)

BOnvo

b)

bonvo

c)

voyage

d)

VOYAGE

9.

What is the output of the following code?

s="INDIA".lower()

print(s)

a)

India

b)

india

c)

INDIA

d)

INDIAlower

10.
What will the output be from the following code?
print("Hello" + str(2) + "world!")
a)
Hello world! Hello world!
b)
Hello2world!
c)
Hello Hello world! world!
d)
SyntaxError
11.

What does the following code do?

myAge = int(myAge)

a)

Converts the var (variable) myAge to a string

b)

Converts the var (variable) myAge to a integer

c)

Converts the var (variable) myAge from a integer to a string

d)

Converts the var (variable) myAge to if statement

12.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing