NEW
Font size
WorksheetsPython Libraries: Basics, Math, and Random
Total questions: 15
Worksheet time: 8mins
What is a program library in Python?
A file for images
A book of stories
A collection of useful code
A computer game
Why do we use libraries in Python?
To change the computer color
To avoid writing long code
To make the computer slower
To delete programs
Which keyword is used to bring a library into a Python program?
use
add
import
include
Which of the following is a Python library?
math
keyboard
screen
calculator
What does the math library help us do?
Play sounds
Perform mathematical calculations
Draw pictures
Store files
Which line correctly imports the math library?
include math
get math
use math
import math
After importing math, how do we use a function from it?
math + function
function()
math.function()
function.math()
Which function gives the square root of a number in the math library?
sqrt()
root()
square()
power()
What is a function in a library?
A file name
A mistake in code
A small program that does a task
A computer virus
Which library is used to work with random numbers?
random
time
turtle
math
What does random.randint(1, 5) do?
Chooses a number between 1 and 5
Prints letters
Which Python library is commonly used for drawing simple graphics like shapes and patterns?
math library for equations
random library for choices
turtle library for graphics
string library for text
What happens if a program calls turtle.forward(50) without importing the turtle library first?
The program runs much faster
The program shows an error
Nothing different occurs
The computer shuts down
Which symbol correctly uses dot notation to access a function from a library?
; semicolon between names
: colon between names
. period between names
, comma between names
Choose the correct example of calling a function from the math library using dot notation.
sqrt math 9 with spaces
math(9).sqrt wrong order
math.sqrt(9) with parentheses
sqrt(9).math reversed names
