wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basics - Quiz

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following identifier would NOT be accepted by Python?

a)

MalaysiaBoleh100

b)

global

c)

pneumonoultra

d)

FLAG

2.

Which of the following is the slicing operator?

a)

[ ]

b)

{ }

c)

( )

d)

/

3.

What is the output of the following lines of code?

var1 = 12

var1 = 23.4

var1 = "I love AI!"

print(var1)

a)

12

b)

23.4

c)

I love AI!

d)

Error

4.

What is the output from the following lines of code?

a = [2, 4, 8]

a[2] = 6

print(a)

a)

[2, 4, 8]

b)

[2, 6, 8]

c)

[2, 4, 6]

d)

[6, 4, 8]

5.

Which function allows us to add one element to a list at a desired location?

a)

append()

b)

extend()

c)

insert()

d)

pop()

6.

How many parameters are there in the sum() function call below?

sum(1, 3, 5)

a)

0

b)

1

c)

2

d)

3

7.

Which of the following refers to a file containing Python statements and definitions?

a)

function

b)

module

c)

block

d)

attribute

8.

Which control structure allows Python codes to branch out for decision making?

a)

if

b)

while

c)

for

d)

loop

9.

How many times would the while loop execute?

a)

0

b)

1

c)

2

d)

3

10.

Which function transforms a 2D numpy array into a 1D array?

a)

flatten()

b)

ravel()

c)

concatenate()

d)

array()