Lesson Seven Homework
Lesson seven hacks
import random #random library
#This is a magic globe that will predict how many toys you will get this winter
print("How many toys will you get this Christmas?")
randomnumber = random.randint(0,100)
print("You will get ", randomnumber, " toys this Christmas")
This algorithim uses the randint function from the random library to generate a random number in the range of 0-100. The number is then printed for the user to know how many presents they will recieve.
import random #random library
numberone = random.randint(0,2)
numbertwo = random.randint(3,4)
multiplication = numberone * numbertwo
print(numberone, " times ", numbertwo, " is ", multiplication)
- 
An import random function uses the random library to access pre-written segments of code that randomizes numbers. In this case, a number between 0 and 2 is randomized, and a number between 3 and 4 is randomized. We can use these functions to simulate situations such as rolling dice. 
- 
A few other things that we can import other than random are libraries such as flask, NumPy, and pandas. 
3.15.2 Hacks
- 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
colorspinner =  random.randint(1,8)
if colorspinner <= 3:
    print("green")
elif colorspinner <= 5:
    print("blue")
elif colorspinner <= 6:
    print("purple")
elif colorspinner <= 7:
    print("red")
else:
    print("orange")