Hack 1

  • Write a program that uses a library/libraries in any sort of manner.
  • Explain your work/code
import math
# math is a library
x = int(input())
# set input which is a number as the value of x
math.sqrt(x)
# take the square root of x
4.0

Hack 2

  • Write a few lines of code that implements the import function

  • Define what an import random function do

  • List a few other things that we can import other than random

import random
flip = random.randint(1,2)
 
if flip == 1:
    print("Heads")
else:
    print("Tails")
Tails
import math

math.sqrt(81)
9.0

an import random function generates a random number from a given range (kind of like an interval in calc)

some other things we can import are math to do math calculations (ex. square root) and also numpy to do calculus (ex. derivatives)

Hack 3

  • 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
spin = random.randint(1,8)

if spin >=3:
    print("green")

elif spin == 4 or 5:
    print("blue")

elif spin == 6:
    print("purple")

elif spin == 7:
    print("red")

elif spin == 8:
    print("orange")
green

What numbers can be outputted from RANDOM(12,20) and what numbers are excluded?
any number from 12 to 20 including 12 and 20
any number that is less than 12 and greater than 20 is excluded