wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Quiz

Total questions: 10

Worksheet time: 20mins

Name
Class
Date
1.

what is the output of print str * 2 if str = 'Hello World!'?

a)

Hello World!Hello World!

b)

Hello World! * 2

c)

Hello World!

d)

None of the above

2.

what is the result of the following operation in Python:

3+ 2 * 2

a)

10

b)

12

c)

9

d)

7

3.

If you executed name = 'Lizz' , what would be the output of print (name[0:2])?

a)

Li

b)

Zz

c)

Lizz

d)

L

4.

If you executed var = '01234567' , what would be the result of print(var[::2])?

a)

0246

b)

01234

c)

1234

d)

7531

5.

what is the result of the following operation '1'+'2'

a)

3

b)

1

c)

2

d)

12

6.

Given myvar = 'hello', how would you convert myvar into uppercase?

a)

len(myvar)

b)

upper(myvar)

c)

myvar.upper()

d)

myvar.upper(myvar)

7.

which of the following are valid ways to specify the string literal foo'bar in Python:

a)

"""foo'bar"""

b)

'foo\'bar'

c)

foo'bar

d)

foo"bar

8.

What is the syntax to obtain the first element of the tuple:

A=('a','b','c')

a)

A[‘1’]

b)

A[1]

c)

A[2]

d)

A[0]

9.

After applying the following method, L.append(['a','b']), the following list will only be one element longer.

a)

True

b)

Flase

10.

what signifies the ends of a statement block or suite in Python?

a)

A line that is indented less than previous line

b)

A comment

c)

End

d)

}