Python Random Library Quiz

Python Random Library Quiz

9th Grade

10 Qs

quiz-placeholder

Similar activities

CSP: Unit 3 - Block Code Types

CSP: Unit 3 - Block Code Types

9th - 12th Grade

12 Qs

PC's

PC's

7th - 12th Grade

10 Qs

CompSci Unit 2 Review

CompSci Unit 2 Review

9th - 12th Grade

14 Qs

Python Basics

Python Basics

KG - University

15 Qs

c++ last

c++ last

1st Grade - University

13 Qs

OTR10

OTR10

9th Grade

15 Qs

Edublocks D01

Edublocks D01

6th - 9th Grade

8 Qs

Create with Code Prototype 2 Quiz

Create with Code Prototype 2 Quiz

9th - 12th Grade

10 Qs

Python Random Library Quiz

Python Random Library Quiz

Assessment

Quiz

Computers

9th Grade

Hard

Created by

Stu Lee

Used 3+ times

FREE Resource

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

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?