wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Review String

Total questions: 21

Worksheet time: 11mins

Name
Class
Date
1.

Python accepts single ('), double (") and triple (''' or """) quotes to denote strings. Which of the following is NOT acceptable Python syntax?

a)

print('Hello World')

b)

print("Hello World")

c)

print('Hello World")

d)

print(""'Hello World'"")

2.

What is printed by the following statement?

print("P" not in "APCSP")

a)

True

b)

False

c)

Error

3.

What is printed by the following statement?

print("A" in "APCSP")

a)

True

b)

False

c)

Error

4.

Evaluate the following expression:

"dog" < "Dog"

a)

They are the same word

b)

True

c)

False

5.

For strings, the + operator represents

a)

Concatenation

b)

Addition

c)

Appending

d)

Recantation

6.

data = "No Way!" The expression len(data) evaluates to:

a)

7

b)

9

c)

8

d)

6

7.

Which operator returns True if target string is somewhere in the search string; otherwise it returns False.

a)

==

b)

!=

c)

in

d)

is

8.

What syntax can you use to insert a line break between strings so that they appear over multiple lines?

a)

\l

b)

/

c)

\\n

d)

\n

9.

Which is the most appropriate data type for: "13th December"

a)

Float

b)

Boolean

c)

Integer

d)

String

10.

What will the output be from the following code?

print("Hello world!" * 2)

a)

TypeError

b)

Hello world world!

c)

Hello world!Hello world!

d)

Hello world! * 2

11.

What will the output be from the following code?

print("Hello world!\nHello world!")

a)

Hello world! Hello world!

b)

Hello world!

Hello world!

c)

SyntaxError

d)

Hello world!

12.

What will the output be from the following code?

print("3+4")

a)

7

b)

34

c)

3+4

d)

SyntaxError

13.

print("12"*3)

What would this print?

a)

121212

b)

36

c)

24

d)

12*3

14.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
15.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
16.

Each item in a string has an "address" or index. The first index in a Python string is what?

a)

0

b)

1

c)

a

d)

A

17.
What output will this code produce?
a)
Exeter
b)
4
c)
6
d)
city
18.
What output will this code produce?
a)
4
b)
2
c)
3
d)
5
19.
What output will this code produce?
a)
1
b)
3
c)
2
d)
4
20.

What is the output from this code?

a)

ell

b)

llo

c)

ello,

d)

Hello

21.

What is the output from this code?

a)

, W

b)

Wor

c)

orl

d)

lro