Unit 2 Binary/Data Terms

  • Bits: A binary digit. Smallest unit of data a computer can process ( 1 or 0 ; true or false) Bytes: Unit of data that is 8 bits long
  • Hexadecimal: Numbering system with base 16 (1-9 and then A-F)
  • Nibbles: four bits (half of a byte)
  • Binary Numbers: numbering scheme where each digit must be 0 or 1. Powers of 2
  • Unsigned Integer: 32-bit and encodes non negative integers
  • Signed Integer: 32-bit includes negative integers
  • Floating Point: Number with a decimal point
  • Binary Data Abstractions: Using Binary (true or false) to sort through data and remove elements that aren't relevant
  • Boolean: Binary variable, True or false
  • ASCII: character encoding format for data that is text
  • Unicode: ANother character encoding format for text data: "Hello" is written U+0048 U+0065 U+006C U+006C U+006F
  • RGB: stands for red green blue. HEX is converted shorthand for RGB values
  • Data Compression: compressing data to use fewer bits
  • Lossy: Compresses a file and permanently eliminates information
  • Lossless (not discussed yet): Every bit of original data remains if file is uncompressed

Unit 3 Algorithm/Programming Terms

a = 'hello' # String Data Type 
b = True # Boolean Data Type
c = 5 # Integer Data Type
d = 4.33 # Float Data Type
print(a)
print(b)
print(c)
print(d)
hello
True
5
4.33
list1_d = [3, 4, 2, 1, 5, 6, 7] 
list2_d = [[2,3,6,5,], [3, 5, 6, 2], [4, 5, 2, 5]]
dict = { 
        'key1' : 1, 
        'key2' : 2, 
        'key3' : 3
        }
#Python If, Elif, Else conditionals; 
# Python Def procedures, Parameters, Return Values
list1_d = [3,4,2,1,5,6,7]
def addnum(num):  #algorithm, Python Def procedures, Parameters
    for i in list1_d:   #Iteration
        if num > i:  #If
            list1_d.append(num)
            print(list1_d)
            break
        elif num < i: #elif
            list1_d.pop(0) 
            print(list1_d) 
        else: # else
            break
addnum(2)
addnum(12)
[4, 2, 1, 5, 6, 7]
[4, 2, 1, 5, 6, 7, 12]
i = 0
while i < len(list1_d):   # Iterating through while loops
  print(list1_d[i])
  i = i + 1
4
2
1
5
6
7
12

a = "Python is "
b = "fun"
c =  a + b
print(c)
Python is fun
num = -89
if num >= 0:
    if num == 0:
        print("Zero")
    else:
        print("Positive ")
else:
    print("Negative")
Negative
num = 5
for number in range(num):
   if number%2 == 0:
      print(number, "is divisible by 2.")
   else:
      print(number, "is not divisible by 2.")
0 is divisible by 2.
1 is not divisible by 2.
2 is divisible by 2.
3 is not divisible by 2.
4 is divisible by 2.

3.1 and 3.2 : Variables and Data Abstraction

  • Defining Variables in Python: Type the variable name (no spaces) and use = to assign a value to it
  • Mathematical Expressions : variable defined using a numerical value . That variable can be used in expressions in the place of a regular number
  • Functions on Lists : append function adds elements to list
  • Data Abstraction: the storage of data in abstract variables
  • Dictionaries : Dictionary can be defined using curly brackets
  • Interchanging Variables : you can interchange variables by setting them equal to each other with a temporary variable
  • Floats: used in the same was as int types, are decimals

3.3 and 3.4: Mathematical Expressions and Strings

  • Algorithm: a set of instructions that tells a program what to do
  • Concatenation: combining strings. In python use + or , between strings to concatenate

3.5 and 3.6 Booleans and Logical Operators

  • Logical operators: and, or, not. These operators compare values
  • Boolean: Return True or False. Return only one of two values similar to binary

3.7 Nested Conditional Statements

Conditional: code proceeds if condition written is met: ex if/else statements Nested conditionals: conditionals within conditionals

3.8, 3.10 (our presentation, see group fastpages for vocab)

3.11 Search:

  • Sequential Search: search method that iterates through each index of a series of data (inefficient compared to binary)

  • Binary Search: search method starts at median of the data, compares to the target value and ignores part of the list that doesn't have the target. The numbers must be in numerical order for this method, this method works fast

3.12 Calling Procedures:

  • Procedure: defined programming instructions. Can have paramters and they return a value. Often called a function

  • Parameters: Inputs of a procedure.

  • Arguments: specify the values of the parameters when a procedure is called

3.13 Developing Procedures:

  • Modularity: organizing the procedures in a program into seperate block based on what task they achieve

  • Procedural Abstraction: naming a process , defining a function by name by what it does

3.14 Libraries:

  • Library: are imported through packages, contain many prewritten procedure

  • Packages: collections of methods which come from libraries libraries

  • Documentation: written explanation of what a procedure/code does. Pseudo code but in words

def multiply(x, y):
    z = x*y
    return z

multiply(6, 4)
24

3.15 Random Values

  • Random Values : a number generated using a large set of numbers and a mathematical algorithm which gives equal probability to all number occuring
import random
random_number = random.randint(1,100)
print(random_number)
32

3.16 Simulations

Simulations: Simulations are abstractions that mimic more complex objects or phenomena from the real world to draw inferences about things we cant observe

  • Variability and randomness in the world can be the reason behind bias in simulations

3.17 + 3.18 Algorithmic Efficiency and Undecidable Problems

  • A decidable problem will always have a definite answer
  • An undecidable problem will either have multiple answers or can not get to the answer in a set amount of time
  • Problem: a general description of a task that can or cannot be solved algorithmically
  • Decision Problem: A problem with a yes or no answer
  • Organization Problem: a problem with a goal of finding the best answer
  • Instance: a problem with a specific input
  • Efficiency: amount of computing needed to solve a problem
  • Polynomial Efficiency (Good): more work takes a proportional amount of time (1 job is +2 time)
  • Exponential Efficiency (Bad): more work takes an exponential amount more time (1 job is 2x time)
  • Heuristic Approach: When optimal solutions are inefficient, look for a possibly optimal solution that is more efficient
  • Decidable Problem: A decision problem that has a clear solution that will always make a correct output
  • Undecidable Problem: A decision problem with no solution that is not gaurenteed to produce the correct output