Notes

  • Library: a collection of code from an external source can be used for adding functionality to a program, included in a program using a special keyword ""
  • Libraries are useful because it saves time and effort in development process

Hack 1

Example of Library

import math

math.sqrt(121)
11.0

This is an example of a code that uses libraries. I used this example because I am really good at math. For the following code, the output of it is 11 because the square root is 121 is 11.

Hack 2

Randomization generates a value between two numbers.

import random


print("How many family members will I visit for Christmas")
randomnumber = random.randint(0,100)


print("You will visit ", randomnumber, " families for Christmas")
How many family members will I visit for Christmas
You will visit  52  families for Christmas

An input random function can import code from another source that contains randomization.

The import function can import things other than random such as flask, NumPy, and pandas.

Hack 3

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")
blue

RANDOM(12,20) can output numbers 12, 13, 14, 15, 16, 17, 18, 19, & 20. Numbers greater than 20 and numbers less than 12 are excluded.