Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CSP apple dropping code interpreting

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is the file name of the image used to represent the apple in the code?

a)

apple.png

b)

apple.gif

c)

background.gif

d)

tree.gif

2.

Which Python module is imported and used for graphics in this code?

a)

math

b)

random

c)

turtle

d)

pygame

3.

What function is called to make the screen aware of the new apple image file?

a)

wn.bgpic()

b)

wn.addshape()

c)

wn.setup()

d)

wn.listen()

4.

What is the background image file set in the code?

a)

apple.gif

b)

background.gif

c)

tree.gif

d)

ground.gif

5.

Which function is responsible for displaying the letter "A" on the apple?

a)

drop_apple()

b)

draw_apple()

c)

draw_letter()

d)

mainloop()

6.

What does the function drop_apple() do?

a)

Changes the apple's color

b)

Moves the apple to the ground height

c)

Draws a line as the apple falls

d)

Writes a letter on the apple

7.

Which key must be pressed to make the apple drop in the program?

a)

"d"

b)

"a"

c)

"s"

d)

"space"

8.

What is the purpose of the penup() method called on the apple turtle?

a)

To change the apple's color

b)

To prevent the apple from drawing lines as it moves

c)

To make the apple fall faster

d)

To write letters on the apple

9.

Why does the code use the setpos() method twice in the draw_letter() function?

a)

To move the apple to a random position

b)

To write the letter and then return the apple to its original position

c)

To change the apple's color

d)

To drop the apple

10.

What would happen if you removed the wn.listen() line from the code?

a)

The apple would not appear

b)

The background would not load

c)

The program would not respond to key presses

d)

The apple would drop automatically

11.

If you wanted to display a different letter on the apple, which part of the code would you modify?

a)

The apple_image variable

b)

The argument in draw_letter() inside draw_apple()

c)

The ground_height variable

d)

The wn.bgpic() function

12.

Suppose you want the apple to drop when the "b" key is pressed instead of "a". What should you change?

a)

Change "a" to "b" in wn.onkeypress(drop_apple, "a")

b)

Change apple_image to "b"

c)

Change draw_letter("A", active_apple) to draw_letter("B", active_apple)

d)

Change ground_height to 0

13.

If the apple_letter_x_offset is changed from -25 to 0, what will be the effect?

a)

The letter will not appear

b)

The letter will be centered horizontally on the apple

c)

The apple will not drop

d)

The background will change

14.

How does the code ensure that the apple does not draw a line as it falls?

a)

By using the penup() method on the apple turtle

b)

By setting the background image

c)

By calling wn.listen()

d)

By using the write() method

15.

If you wanted to make the apple fall to a different height, which variable would you modify?

a)

apple_image

b)

ground_height

c)

apple_letter_x_offset

d)

wn.bgpic

16.

Suppose you want to display the letter "B" on the apple when the "b" key is pressed, and "A" when the "a" key is pressed. How would you modify the code to achieve this?

a)

Add another onkeypress event for "b" that calls a function to draw "B" on the apple

b)

Change the apple_image variable to "B"

c)

Remove the draw_letter() function

d)

Set ground_height to 0

17.

If you wanted to allow the user to type any letter and have it appear on the apple, what programming concept would you need to use?

a)

A loop that draws the apple repeatedly

b)

An event handler that captures key presses and passes the pressed key to draw_letter()

c)

Changing the background image

d)

Using penup() and pendown() methods

18.

Imagine you want the apple to fall smoothly (animated) instead of instantly jumping to the ground. What kind of programming structure would you use to implement this?

a)

A for loop or while loop that gradually changes the y-coordinate of the apple

b)

Change the apple_image variable

c)

Use wn.bgpic() repeatedly

d)

Remove the penup() method

19.

If you wanted to have multiple apples on the tree, each with a different letter, what would be an effective way to manage them in the code?

a)

Create a list of turtle objects, each representing an apple, and assign a letter to each

b)

Use only one turtle and change its position repeatedly

c)

Change the background image for each apple

d)

Use a single variable for all apples

20.

How could you modify the code so that the apple only drops if the correct letter is typed (for example, the letter displayed on the apple)?

a)

Add a check in the key event handler to compare the pressed key with the displayed letter before calling drop_apple()

b)

Remove the draw_letter() function

c)

Change the apple_image variable

d)

Set ground_height to 0