Unit 3 Sections 14 and 15 Hacks
import math
sqrt = math.sqrt(int(input()))
print(sqrt)
- import random function imports the random dictionary and choses a random number between the set range.
- you can import flask, dictionary, and you can install many more library
Hacks 3.15.2
- For your hacks you need to create a random number generator that will simulate this situation:
-
There is a spinner divided into eight equal parts. 3 parts of the spinner are green, two parts are blue, one part is purple, one part is red, and one part is orange. How can you simulate this situation using a random number generator.
-
Also answer this question: What numbers can be outputted from RANDOM(12,20) and what numbers are excluded?
import random
rand = random.randint(1,6)
if rand == (1 or 2 or 3):
print ("green")
if rand == (4 or 5):
print ("blue")
else:
print("red")
- the numbers that can be choses are 12 trough 20 and the numbers that are excluded are the ones that are not in the restriction