Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Random and Turtle Quiz

Total questions: 40

Worksheet time: 30mins

Name
Class
Date
1.

What is the output of random.randint(2, 8)?

a)

A random integer between 2 and 7

b)

A random float between 2 and 8

c)

A random integer between 2 and 8 (inclusive)

d)

Always returns 5

2.

Which is the correct way to import the random module to use randint?

a)

import randint

b)

from os import random

c)

import random

d)

from math import randint

3.

What happens when random.randint(1, 1) is executed?

a)

Returns 1

b)

Returns None

c)

Raises an error

d)

Returns a random number between 0 and 1

4.

Which of these random.randint() calls is invalid?

a)

random.randint(1, 100)

b)

random.randint(5, 10)

c)

random.randint(-5, 5)

d)

random.randint(10, 5)

5.

What is the primary use of the random module?

a)

Sorting lists alphabetically

b)

Generating random numbers or selections

c)

Creating random images

d)

Performing mathematical calculations

6.

What does pen.penup() do in the Turtle module?

a)

Moves the turtle backward

b)

Lowers the pen to start drawing

c)

Lifts the pen to stop drawing

d)

Rotates the turtle

7.

Which command correctly moves the turtle forward by 50 units?

a)

pen.forward(50)

b)

pen.up(50)

c)

turtle.left(50)

d)

turtle.move(50)

8.

How can you make the turtle rotate right without changing its position?

a)

pendown(90)

b)

right(90)

c)

pen.right(90)

d)

turtle.shape('right')

9.

What does turtle.left(45) do?

a)

Rotates the turtle 45 degrees clockwise

b)

Moves the turtle backward by 45 units

c)

Moves the turtle forward by 45 units

d)

Rotates the turtle 45 degrees counterclockwise

10.

Which function stops the pen from drawing when the turtle moves?

a)

pendown()

b)

turtle.stopdraw()

c)

turtle.drawstop()

d)

penup()

11.

Which condition correctly checks if a number is even?

a)

if a // 2 != 0:

b)

if a % 2 == 0:

c)

if a % 2 != 0:

d)

if a // 2 == 0:

12.

What does the OR logical operator do?

a)

Represents 'Or'

b)

No correct answer

c)

Represents 'Not'

d)

Represents 'And'

13.

Which condition correctly checks if a number is both odd and positive?

a)

if a % 2 != 0 or a > 0:

b)

if a % 2 == 0 or a > 0:

c)

if a % 2 != 0 and a > 0:

d)

if a % 2 == 0 and a > 0:

14.

Which block of code executes if none of the conditions in an if-elif chain are met?

4 lines
15.

Which condition correctly checks if a number is divisible by 5?

a)

if 5 % a == 0:

b)

if a // 5 == 0:

c)

if a % 5 != 0:

d)

if a % 5 == 0:

16.

What is the correct notation for the 'greater than or equal to' comparison operator?

4 lines
17.

What is the meaning of the elif keyword in Python?

a)

No correct answer

b)

If

c)

Otherwise if

d)

Otherwise

18.

Which logical operator returns True only if all conditions are True?

4 lines
19.

Which is the first block used when writing a conditional statement?

a)

elif

b)

else if

c)

if

d)

else

20.

What is the correct syntax for the 'equal to' comparison operator?

4 lines
21.

Which is the correct way to create a Turtle object in Python?

a)

pen = Turtle.turtle()

b)

pen = Turtle()

c)

pen = turtle.Turtle()

d)

pen = turtle()

22.

Which command moves the turtle forward by 100 pixels?

a)

pen.forward(100)

b)

pen.walk(100)

c)

pen.go(100)

d)

pen.move(100)

23.

How do you turn the turtle 90 degrees to the right?

a)

pen.right(90)

b)

pen.turn(90)

c)

pen.angle(90)

d)

pen.rotate(90)

24.

Which function lifts the pen so it does not draw while moving?

a)

pen.penup()

b)

pen.lift()

c)

pen.off()

d)

pen.nodraw()

25.

Which function lowers the pen to resume drawing?

a)

pen.down()

b)

pen.pendown()

c)

pen.drawon()

d)

pen.startdraw()

26.

How do you set the pen color to red?

a)

pen.color("red")

b)

pen.setcolor("red")

c)

pen.set_pen_color("red")

d)

pen.change_color("red")

27.

Which command changes the turtle’s shape to a turtle?

a)

pen.shape("turtle")

b)

pen.setshape("turtle")

c)

pen.changeshape("turtle")

d)

pen.turtle_shape()

28.

Which function sets the pen size to 5?

a)

pen.set_pen_size(5)

b)

pen.pensize(5)

c)

pen.size(5)

d)

pen.setsize(5)

29.

How can you fill a shape with color?

a)

pen.fillcolor("blue")

b)

pen.color_fill("blue")

c)

pen.setfill("blue")

d)

pen.fill("blue")

30.

Which function starts filling a shape with the current fill color?

a)

pen.begin_fill()

b)

pen.start_fill()

c)

pen.fillstart()

d)

pen.fill_begin()

31.

Which command stops filling a shape?

a)

pen.fill_end()

b)

pen.stop_fill()

c)

pen.end_fill()

d)

pen.fillstop()

32.

How do you draw a circle with a radius of 50?

a)

pen.draw_circle(50)

b)

pen.make_circle(50)

c)

pen.setcircle(50)

d)

pen.circle(50)

33.

How can you speed up the turtle’s movement?

a)

pen.turbomode(10)

b)

pen.movespeed(10)

c)

pen.set_speed("fast")

d)

pen.speed(10)

34.

What is the slowest speed setting for the turtle?

a)

1

b)

5

c)

10

d)

0

35.

What happens when pen.speed(0) is used?

a)

Sets the turtle to the slowest speed

b)

Stops the turtle

c)

Sets the turtle to the fastest speed

d)

Resets the turtle’s speed

36.

Which loop is best for repeating a drawing command multiple times?

a)

while loop

b)

for loop

c)

if statement

d)

repeat command

37.

How do you use a loop to draw a square with sides of length 100?

a)

for i in range(4): pen.forward(100) pen.right(90)

b)

repeat 4: pen.forward(100) pen.right(90)

c)

loop(4): pen.forward(100) pen.right(90)

d)

while i < 4: pen.forward(100) pen.right(90)

38.

What is the purpose of turtle.done()?

a)

Ensures the drawing window stays open

b)

Stops the program from running

c)

Resets the turtle’s position

d)

Clears the drawing screen

39.

What does pen.goto(50, 100) do?

a)

Moves the turtle randomly

b)

Moves the turtle forward by 50 and upward by 100

c)

Moves the turtle backward by 50 and left by 100

d)

Moves the turtle to coordinates (50, 100)

40.

What happens if you use pen.hideturtle()?

a)

The turtle disappears and stops drawing

b)

The drawing is erased

c)

The turtle stops moving

d)

The turtle disappears but still draws