wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python 101 Grade 8

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

The followings are valid ways to comment on a code in Python?


#hello


'''world

is good'''

a)

True

b)

False

2.

Which of the following is a valid function?

a)

run

b)

forward

c)

forward()

d)

forward;

3.

Which one of the following moves the actor three times?

a)

move()

move()

move()

b)

move() *3

c)

forward()

forward()

forward()

d)

forward() {3}

4.

In Python, a variable or identifier starts with only a letter or an underscore. Which of the following is a valid variable or identifier? Select all that apply.

a)

2_count

b)

3_COUNT_NUMBER

c)

_identifier

d)

#count

5.

Which one of the following is a valid example of commenting in Python?

a)

#Here we have some code

b)

Here we have some code

c)

_here_there_is_a_code

d)

_3code

6.

Which of the following is a valid example of a "snake case" in Python?

a)

_my_variable_

b)

myVariable

c)

_mycode#

d)

my_code

7.

An identifier starts with an underscore "_".

a)

True

b)

False

8.

Commented lines affect the execution of the program.

a)

True

b)

False

9.

'''Hello

World''' is the correct way to comment multiple lines in Python.

a)

True

b)

False

10.

The following code will print "Hello" 12 times.

for i in range(3):

for j in range(4):

print('Hello')

a)

True

b)

False

11.

How many times the following "for-loop" will be executed?


for i in range(12,8,-1):

a)

3

b)

4

c)

5

d)

6

12.

Which one of the following is the incorrect for-loop?

a)

for 4 in range():

b)

for i in range(6):

c)

for i in range(1,5):

d)

for i in range(8,3,-1):

13.

Which of the following is the correct way to run all numbers from 0 to 8?

a)

for i in range(8):

b)

for i in range(1,8):

c)

for i in range(9):

d)

for i in range(-8):

14.

For-loops can increment upward and downward, such as:

for i in range(1,10,2): and for i in range(10,1,-2):

a)

True

b)

False

15.

for i in range(25):

for j in range(4):

forward()

How many times the "forward()" function will run?

a)

29

b)

100

c)

21

d)

25