wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Codesters: Python Functions and Indexes

Total questions: 27

Worksheet time: 14mins

Name
Class
Date
1.

How can we debug this code?

a)

Nest the commands inside the panther functions

b)

Nest panther() inside the panther function

c)

Change the sprite's variable name to panther

d)

Delete panther()

2.

How do we debug this code?

a)

Set a new background

b)

Nest line 13 under the function

c)

Use an If Statement on line 12

d)

Change line 13 to: subway_ride()

3.

How do we debug this code?

a)

Change the dogs name to Fido

b)

Rename the function

c)

Un-nest line 22

d)

Tab over line 10

4.

How many times will the function fetch run?

a)

1 Time

b)

2 Times

c)

3 Times

d)

It will not run. There is a bug in the code.

5.

How do we debug this code?

a)

Add a background

b)

Change the sprites name

c)

Nest line 18 under the function

d)

Change the function name

6.

Which function runs first

a)

blast_off

b)

encounter

c)

ship

d)

alien

7.

Which line calls the function that launches the ship

a)

def blast_off()

b)

def encounter()

c)

blast_off()

d)

encounter()

8.

If you want to run the dance function after the blast_off, which line would you use to call the function?

a)

11

b)

28

c)

30

d)

32

9.

How many times will the sway function run?

a)

0

b)

1

c)

2

d)

3

10.

How many times will the two_step function run?

a)

0

b)

1

c)

2

d)

3

11.

What is the name of the function

a)

moon

b)

robot

c)

def

d)

blast off

12.

Which line calls the function

a)

def moon():

b)

stage.set_background("moon")

c)

sprite.say("...blast off"")

d)

moon()

13.

Which line defines the function?

a)

def moon():

b)

stage.set_background("moon")

c)

sprite.say("...blast off"")

d)

moon()

14.

How do you debug this code?

a)

Change the name on the call function

b)

Move snow() to line 14

c)

Tab line 3 over

d)

Add a sprite on line 2

15.

How do you debug this code?

a)

Tab line 10 over

b)

Change the name of the function to dino_band

c)

Un-tab lines 5-7

d)

Set the sprite speed to 7

16.

What is an Index?

a)

How fast your program runs

b)

The name of a list

c)

The number of items in a list

d)

The word we use to talk about position of a value inside of a list

17.

new_pets = ["panther", "pig", "fox", "dinosaur"]

selected_pet = new_pets[ ]


Which number should go inside the index in order to select the dinosaur??

a)

1

b)

2

c)

3

d)

4

18.

new_pets = ["panther", "pig", "fox", "dinosaur"]

selected_pet = new_pets[ ]


Which number should go inside the index in order to select the panther??

a)

1

b)

2

c)

3

d)

0

19.

new_pets = ["panther", "pig", "fox", "dinosaur"]

selected_pet = new_pets[ ]


Which number should go inside the index in order to select the pig??

a)

1

b)

2

c)

3

d)

0

20.

Which pet is currently selected by the index?

a)

panther

b)

pig

c)

fox

d)

dinosaur

21.

If you added a fifth pet to the end of the list, what would its index be?

a)

0

b)

4

c)

5

d)

6

22.

Which image is stored by character_image?

a)

princess2

b)

superhero1

c)

alien1

d)

zombie2

23.

Which index would you use to select princess2?

a)

0

b)

1

c)

2

d)

3

24.

If you changed the index to 3, which image would be stored?

a)

princess2

b)

superhero1

c)

alien1

d)

zombie2

25.

What would happen if you changed the index to 4?

a)

An error message would occur

b)

superhero1 would be stored

c)

alien1 would be stored

d)

zombie2 would be stored

26.
a)

a

b)

b

c)

c

d)

d

27.
a)

a

b)

b

c)

c

d)

d