wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python String

Total questions: 6

Worksheet time: 6mins

Name
Class
Date
1.

What character will be printed on the screen after running this Python code:

a)

a

b)

l

c)

L

d)

Nothing is printed

2.

What character will be printed on the screen after running this Python code:

a)

r

b)

u

c)

a

d)

Nothing is printed

3.

What output will this Python code produce?

a)

Kuala Lumpur

b)

11

c)

12

d)

x

4.

What output will this Python code produce?

a)

M

b)

s

c)

Msl

d)

Mly

5.

Consider this statement:

print(r'foo\\bar\nbaz')


Which of the following is the correct REPL output?

a)

foo\bar\nbaz

b)

foo\bar

baz

c)

foo\\bar\nbaz

d)

foo\\barnbaz

6.

Which of the following Python codes produce the following output (you can select multiple answers)?

I haven't eaten all day and I don't feel hungry.

a)

print("I haven't eaten all day and I don't feel hungry")

b)

print('I haven't eaten all day and I don't feel hungry')

c)

print('I haven\'t eaten all day and I don\'t feel hungry')

d)

print('I haven"t eaten all day and I don"t feel hungry')