WorksheetsPython Random and Turtle Quiz
Total questions: 40
Worksheet time: 30mins
What is the output of random.randint(2, 8)?
A random integer between 2 and 7
A random float between 2 and 8
A random integer between 2 and 8 (inclusive)
Always returns 5
Which is the correct way to import the random module to use randint?
import randint
from os import random
import random
from math import randint
What happens when random.randint(1, 1) is executed?
Returns 1
Returns None
Raises an error
Returns a random number between 0 and 1
Which of these random.randint() calls is invalid?
random.randint(1, 100)
random.randint(5, 10)
random.randint(-5, 5)
random.randint(10, 5)
What is the primary use of the random module?
Sorting lists alphabetically
Generating random numbers or selections
Creating random images
Performing mathematical calculations
What does pen.penup() do in the Turtle module?
Moves the turtle backward
Lowers the pen to start drawing
Lifts the pen to stop drawing
Rotates the turtle
Which command correctly moves the turtle forward by 50 units?
pen.forward(50)
pen.up(50)
turtle.left(50)
turtle.move(50)
How can you make the turtle rotate right without changing its position?
pendown(90)
right(90)
pen.right(90)
turtle.shape('right')
What does turtle.left(45) do?
Rotates the turtle 45 degrees clockwise
Moves the turtle backward by 45 units
Moves the turtle forward by 45 units
Rotates the turtle 45 degrees counterclockwise
Which function stops the pen from drawing when the turtle moves?
pendown()
turtle.stopdraw()
turtle.drawstop()
penup()
Which condition correctly checks if a number is even?
if a // 2 != 0:
if a % 2 == 0:
if a % 2 != 0:
if a // 2 == 0:
What does the OR logical operator do?
Represents 'Or'
No correct answer
Represents 'Not'
Represents 'And'
Which condition correctly checks if a number is both odd and positive?
if a % 2 != 0 or a > 0:
if a % 2 == 0 or a > 0:
if a % 2 != 0 and a > 0:
if a % 2 == 0 and a > 0:
Which block of code executes if none of the conditions in an if-elif chain are met?
Which condition correctly checks if a number is divisible by 5?
if 5 % a == 0:
if a // 5 == 0:
if a % 5 != 0:
if a % 5 == 0:
What is the correct notation for the 'greater than or equal to' comparison operator?
What is the meaning of the elif keyword in Python?
No correct answer
If
Otherwise if
Otherwise
Which logical operator returns True only if all conditions are True?
Which is the first block used when writing a conditional statement?
elif
else if
if
else
What is the correct syntax for the 'equal to' comparison operator?
Which is the correct way to create a Turtle object in Python?
pen = Turtle.turtle()
pen = Turtle()
pen = turtle.Turtle()
pen = turtle()
Which command moves the turtle forward by 100 pixels?
pen.forward(100)
pen.walk(100)
pen.go(100)
pen.move(100)
How do you turn the turtle 90 degrees to the right?
pen.right(90)
pen.turn(90)
pen.angle(90)
pen.rotate(90)
Which function lifts the pen so it does not draw while moving?
pen.penup()
pen.lift()
pen.off()
pen.nodraw()
Which function lowers the pen to resume drawing?
pen.down()
pen.pendown()
pen.drawon()
pen.startdraw()
How do you set the pen color to red?
pen.color("red")
pen.setcolor("red")
pen.set_pen_color("red")
pen.change_color("red")
Which command changes the turtle’s shape to a turtle?
pen.shape("turtle")
pen.setshape("turtle")
pen.changeshape("turtle")
pen.turtle_shape()
Which function sets the pen size to 5?
pen.set_pen_size(5)
pen.pensize(5)
pen.size(5)
pen.setsize(5)
How can you fill a shape with color?
pen.fillcolor("blue")
pen.color_fill("blue")
pen.setfill("blue")
pen.fill("blue")
Which function starts filling a shape with the current fill color?
pen.begin_fill()
pen.start_fill()
pen.fillstart()
pen.fill_begin()
Which command stops filling a shape?
pen.fill_end()
pen.stop_fill()
pen.end_fill()
pen.fillstop()
How do you draw a circle with a radius of 50?
pen.draw_circle(50)
pen.make_circle(50)
pen.setcircle(50)
pen.circle(50)
How can you speed up the turtle’s movement?
pen.turbomode(10)
pen.movespeed(10)
pen.set_speed("fast")
pen.speed(10)
What is the slowest speed setting for the turtle?
1
5
10
0
What happens when pen.speed(0) is used?
Sets the turtle to the slowest speed
Stops the turtle
Sets the turtle to the fastest speed
Resets the turtle’s speed
Which loop is best for repeating a drawing command multiple times?
while loop
for loop
if statement
repeat command
How do you use a loop to draw a square with sides of length 100?
for i in range(4): pen.forward(100) pen.right(90)
repeat 4: pen.forward(100) pen.right(90)
loop(4): pen.forward(100) pen.right(90)
while i < 4: pen.forward(100) pen.right(90)
What is the purpose of turtle.done()?
Ensures the drawing window stays open
Stops the program from running
Resets the turtle’s position
Clears the drawing screen
What does pen.goto(50, 100) do?
Moves the turtle randomly
Moves the turtle forward by 50 and upward by 100
Moves the turtle backward by 50 and left by 100
Moves the turtle to coordinates (50, 100)
What happens if you use pen.hideturtle()?
The turtle disappears and stops drawing
The drawing is erased
The turtle stops moving
The turtle disappears but still draws
