wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Libraries: Basics, Math, and Random

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is a program library in Python?

a)

A file for images

b)

A book of stories

c)

A collection of useful code

d)

A computer game

2.

Why do we use libraries in Python?

a)

To change the computer color

b)

To avoid writing long code

c)

To make the computer slower

d)

To delete programs

3.

Which keyword is used to bring a library into a Python program?

a)

use

b)

add

c)

import

d)

include

4.

Which of the following is a Python library?

a)

math

b)

keyboard

c)

screen

d)

calculator

5.

What does the math library help us do?

a)

Play sounds

b)

Perform mathematical calculations

c)

Draw pictures

d)

Store files

6.

Which line correctly imports the math library?

a)

include math

b)

get math

c)

use math

d)

import math

7.

After importing math, how do we use a function from it?

a)

math + function

b)

function()

c)

math.function()

d)

function.math()

8.

Which function gives the square root of a number in the math library?

a)

sqrt()

b)

root()

c)

square()

d)

power()

9.

What is a function in a library?

a)

A file name

b)

A mistake in code

c)

A small program that does a task

d)

A computer virus

10.

Which library is used to work with random numbers?

a)

random

b)

time

c)

turtle

d)

math

11.

What does random.randint(1, 5) do?

a)

Chooses a number between 1 and 5

b)

Prints letters

12.

Which Python library is commonly used for drawing simple graphics like shapes and patterns?

a)

math library for equations

b)

random library for choices

c)

turtle library for graphics

d)

string library for text

13.

What happens if a program calls turtle.forward(50) without importing the turtle library first?

a)

The program runs much faster

b)

The program shows an error

c)

Nothing different occurs

d)

The computer shuts down

14.

Which symbol correctly uses dot notation to access a function from a library?

a)

; semicolon between names

b)

: colon between names

c)

. period between names

d)

, comma between names

15.

Choose the correct example of calling a function from the math library using dot notation.

a)

sqrt math 9 with spaces

b)

math(9).sqrt wrong order

c)

math.sqrt(9) with parentheses

d)

sqrt(9).math reversed names