Search Header Logo

Python Random Library Quiz

Authored by Stu Lee

Computers

9th Grade

Used 13+ times

Python Random Library Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which function from the Python `random` library generates a random integer between two specified numbers?

random.uniform()

random.randint()

random.random()

random.choice()

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does `random.uniform(1, 10)` do in Python?

Generates a random integer between 1 and 10

Generates a random float between 1 and 10

Generates a random integer between 0 and 1

Generates a random float between 0 and 1

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following imports the Python `random` module correctly?

import rand

import random_number

import random

import numbers

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you generate a random choice from a list in Python?

random.choice()

random.list()

random.pick()

random.select()

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of `random.randint(1, 1)`?

Error

0

1

None

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following will generate a random float between 0 and 1?

random.randint(0, 1)

random.random()

random.choice([0, 1])

random.uniform(0, 1)

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does `random.choice(['apple', 'banana', 'cherry'])` return?

A random float

A random integer

A random string from the list

An error

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Microsoft

Continue with Microsoft

or continue with

Facebook

Facebook

Apple

Apple

Others

Others

Already have an account?