Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!