- 6 hours
- Easy
Last updated on 8/2/23
Use Specialized Python Libraries
Evaluated skills
- Use specialized Python libraries
Question 1
Check the numbers that can be obtained if the following code is run:
import random n = random.uniform(10,19) print(n)
Careful, there are several correct answers.6
10.0
14.4
23.0
10.5
19.0
Question 2
What should the ... be replaced with, so that the following program prints one of the names in the list at random?
import random basket = ["Apple", "Pear", "Banana", "Pineapple", "Orange"] result = ... print(result)
Careful, there are several correct answers.basket[random.randint(0, 4)]
random.choice(basket)
random.random(basket)
random.shuffle(basket)
Question 3
Consider the following experiment:
A normally-balanced die (with six faces) is thrown 10,000 times. Among these 10,000 throws, 1,000 are taken at random.
We carry out this experiment five times, and we write down m, the average number of times we get the number six out of the 10,000 throws, and n, the average number of times we get the number four in the subsample.
What would be the values of m and n at the end of this experiment?
Randomness makes the results too variable to answer this question precisely.
m
andn
will be close to 1/6.m
will be close to 1/6,n
will be close to (1/6)/10 = 1/60.m
will be close to 1/6 and it is not possible to know forn
because of the randomness.
- Up to 100% of your training program funded
- Flexible start date
- Career-focused projects
- Individual mentoring