Notes

  • A software library contains procedures that can be used in the creation of new programs.
  • Existing segments of code can come from internal or external sources, ie. libraries or previously written code.
  • The use of libraries simplifies the task of creating complex programs.
  • Application program interfaces (APIs) are specifications for how the procedures in a library behave and can be used.
  • Documentation for a library or API is necessary in understanding the key behaviors provided by the API/library and how to utilize them in your work.
  • A library is a collection of code from an external source that can be used to add functionality to a program.
  • Libraries are very useful, as they can be used to save time and effort in the development process.
  • Libraries are usually included in a program using a special keyword called " ." This keyword tells the program to look for the library and use its code.
  • Randomization generates a random value beteen two numbers

Hacks

Hacks 1

1.

import random 

contestant1 = random.randint(1,10)
contestant2 = random.randint(1,10)
print ('Contestant', contestant1, 'vs', 'contestant', contestant2)
Contestant 2 vs contestant 7
  1. I imported the random library database. By using this I used the random int line of code to choose a bumber between 1 and 10. I then put these two equal to a different variable. Finally I made a print statement to make two random contestents of the ten to go agianst each other. This could be used for making a schedule for a sports league.

Hacks 2

  1. The inport random function imports the database from the random library. It allows us to use new lines of code such as "rand.int". Now we get to make a lot more lines fo code that have to do with randomization
  2. Some other things we can import other than random is math, turtles, flask, dictionary, and sqlalchemy. You can import many things. Different people have made these different libraries so the amount of things you can import is based on what other people have made.

Hack 3

1.

import random

color = random.randint(1,8)

if color == 1 | 2 | 3:
    print('Green')
elif color == 4 | 5:
    print('Blue')
elif color == 6:
    print('Purple')
elif color == 7:
    print('Red')
elif color == 8:
    print('Orange')
Orange
  1. The numbers that are outputted for RANDOM(12,20) are 12, 13, 14, 15, 16, 17, 18, 19, and 20. No numbers are excluded