WorksheetsCSP apple dropping code interpreting
Total questions: 20
Worksheet time: 10mins
What is the file name of the image used to represent the apple in the code?
apple.png
apple.gif
background.gif
tree.gif
Which Python module is imported and used for graphics in this code?
math
random
turtle
pygame
What function is called to make the screen aware of the new apple image file?
wn.bgpic()
wn.addshape()
wn.setup()
wn.listen()
What is the background image file set in the code?
apple.gif
background.gif
tree.gif
ground.gif
Which function is responsible for displaying the letter "A" on the apple?
drop_apple()
draw_apple()
draw_letter()
mainloop()
What does the function drop_apple() do?
Changes the apple's color
Moves the apple to the ground height
Draws a line as the apple falls
Writes a letter on the apple
Which key must be pressed to make the apple drop in the program?
"d"
"a"
"s"
"space"
What is the purpose of the penup() method called on the apple turtle?
To change the apple's color
To prevent the apple from drawing lines as it moves
To make the apple fall faster
To write letters on the apple
Why does the code use the setpos() method twice in the draw_letter() function?
To move the apple to a random position
To write the letter and then return the apple to its original position
To change the apple's color
To drop the apple
What would happen if you removed the wn.listen() line from the code?
The apple would not appear
The background would not load
The program would not respond to key presses
The apple would drop automatically
If you wanted to display a different letter on the apple, which part of the code would you modify?
The apple_image variable
The argument in draw_letter() inside draw_apple()
The ground_height variable
The wn.bgpic() function
Suppose you want the apple to drop when the "b" key is pressed instead of "a". What should you change?
Change "a" to "b" in wn.onkeypress(drop_apple, "a")
Change apple_image to "b"
Change draw_letter("A", active_apple) to draw_letter("B", active_apple)
Change ground_height to 0
If the apple_letter_x_offset is changed from -25 to 0, what will be the effect?
The letter will not appear
The letter will be centered horizontally on the apple
The apple will not drop
The background will change
How does the code ensure that the apple does not draw a line as it falls?
By using the penup() method on the apple turtle
By setting the background image
By calling wn.listen()
By using the write() method
If you wanted to make the apple fall to a different height, which variable would you modify?
apple_image
ground_height
apple_letter_x_offset
wn.bgpic
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?
Add another onkeypress event for "b" that calls a function to draw "B" on the apple
Change the apple_image variable to "B"
Remove the draw_letter() function
Set ground_height to 0
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 loop that draws the apple repeatedly
An event handler that captures key presses and passes the pressed key to draw_letter()
Changing the background image
Using penup() and pendown() methods
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 for loop or while loop that gradually changes the y-coordinate of the apple
Change the apple_image variable
Use wn.bgpic() repeatedly
Remove the penup() method
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?
Create a list of turtle objects, each representing an apple, and assign a letter to each
Use only one turtle and change its position repeatedly
Change the background image for each apple
Use a single variable for all apples
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)?
Add a check in the key event handler to compare the pressed key with the displayed letter before calling drop_apple()
Remove the draw_letter() function
Change the apple_image variable
Set ground_height to 0
