Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON 3 For the questions below, assume that the Python random library has been imported already: >>> from random import * 1. Which of the

PYTHON 3

For the questions below, assume that the Python random library has been imported already:

>>> from random import *

1. Which of the following conditions will be true with probability 1/2?

Group of answer choices

A. random() <= 0.5

B. randint(0,1) == 1

C. choice(['H', 'T']) == 'H'

D.All of the above

2. Suppose you are writing a computer game, and you want to simulate rolling two fair six-sided dice. Which of the following could you use?

Group of answer choices

A. rolls = sample(range(6), 2)

B. rolls = [randrange(1,6), randrange(1,6)]

C. rolls = [randint(1,6), randint(1,6)]

D. rolls = [6*random(), 6*random()]

E. All of the above

3. Assume that you've just typed the following into the Python interpreter:

>>> seed(9) >>> randint(1,10) 8 

What would you predict the output to be if you were to immediately enter the same two commands?

>>> seed(9) >>> randint(1,10) 

Group of answer choices

A. 8

B. 9

C. 10

D. Python gives a ValueError.

E. Can't be certain because of the randomness.

4. Assume that you've just typed the following into the Python interpreter:

>>> seed(6) >>> randint(1,5) 2

What would you predict the output to be if the next command you input were the following:

>>> randint(1,5)

Group of answer choices

A. 4

B. 5

C. 6

D. Python gives a ValueError.

E. Can't be certain because of the randomness.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

=+a. Construct an s chart based on this data.

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago