Hack 3.14.1

This code returns you the number of ways to choose k items from n items without repetition and without order.

import math
math.comb(12,10)
66

Hack 3.15.1

  • Write a few lines of code that implements the import function
  • Define what an import random function do
  • It allows you to pick a random integer from a range.
  • List a few other things that we can import other than random
  • You can also import flask, NumPy, and TensorFlow
import math
num = input("what number do you want to square root?")
squart = math.sqrt(int(num))
print("The root of",num,"is",squart)
The root of 4 is 2.0

Hack 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?

  • It's any number greater than or equal to 12 and less than or equal to 20.
import random
landed_on = random.randint(1,10)
if landed_on <= 4:
    color = "rice"
elif 4<= landed_on <= 6:
    color = "noodle"
elif landed_on == 7:
    color = "fruit"
elif landed_on == 10:
    color = "pizza"

print("The food is", color)
The food is pizza