wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

/Python_Quiz\

Total questions: 20

Worksheet time: 20mins

Name
Class
Date
1.

Which Python code segment will display "Hello, world!" on the screen?

a)

display Hello, world!

b)

print("Hello, world!")

c)

print "Hello, world!"

d)

"Hello, world!"

2.

What type is the following variable? x = "Hi there"

a)

float

b)

integer

c)

boolean

d)

string

3.

What does the following Python program print? x = 12 % 4 print(x)

a)

0

b)

1

c)

3

d)

4

4.
a)

middle age

b)

Young age or middle age

c)

Young age

d)

"Young age or middle age"

5.
a)

Young age

b)

Middle age

c)

Slightly old

d)

Very old

6.
a)

1

3

5

7

9

b)

2

4

6

7

9

c)

1

2

3

4

5

d)

10

9

8

7

6

5

7.

num= [34,56,78,12]

num.append(75)

print(num)

a)

[34,56,,75]

b)

[34,56,]

c)

[34,56,78,12,75]

d)

[34,2,75]

8.

list.remove(element)

num= [1,2,3,4,5,6,7]

print(num.remove(4))

a)

[1,2,3,5,6,7]

b)

[1,2,3,5,7]

c)

[1,2,3,6,7]

d)

[1,,3,5,6,7]

9.

list.reverse()

num= [2,3,4,5,6]

print(num.reverse())

a)

[2,3,4,5,6]

b)

[6,5,7,2]

c)

[6,3,2]

d)

[6,5,4,3,2]

10.

Comments are:

a)

for humans to read and understand

b)

needed when a program is over 50 lines

c)

commands that are performed by the computer

d)

ALWAYS blue

11.

How do you begin a one-line comment?

a)

*

b)

#

c)

+

d)

"

12.

Which is the best variable name?

a)

Draw_Two_Squares

b)

draw_squares

c)

2_squares

d)

print

13.

Why do we use if statements?

a)

to stop our code if there's an error

b)

so the computer will make decisions based on conditions

c)

to run a command

d)

to run one function at a time

14.

Why do we use while loops?

a)

To repeat code a specific number of times

b)

To use if-else statements in a loop

c)

To repeat code when the number of times to repeat is unknown

d)

To determine if a condition is true

15.

What will this output print( 3 + 4 * 5)

a)

23

b)

35

c)

3+4*5

d)

Nothing it will give an error

16.

Identify the type

num=(1,3,5,7,9,3,4)

a)

Tuple

b)

List

c)

Dictionary

d)

keys

17.

Founder of Python?

a)

Guido van Rossum

b)

Tim Berners Lee

c)

Charles Babbage

d)

None of them

18.

What type of Language is Python?

a)

Machine Language

b)

Assembly Language

c)

High level Language

d)

None of them

19.

Which is Python Keyword?

a)

Apple

b)

input

c)

john

d)

number

20.

Is Python case sensitive when dealing with identifiers?

a)

a) yes

b)

b)no

c)

c) machine dependent

d)

d) none of the mentioned