Terms

Unit 2… Binary/Data Terms Bits, Bytes, Hexadecimal / Nibbles Binary Numbers: Unsigned Integer, Signed Integer, Floating Point Binary Data Abstractions: Boolean, ASCII, Unicode, RGB Data Compression: Lossy, Lossless (note discussed yet)

Unit 3… Algorithm/Programming Terms Variables, Data Types, Assignment Operators Managing Complexity with Variables: Lists, 2D Lists, Dictionaries, Class Algorithms, Sequence, Selection, Iteration Expressions, Comparison Operators, Booleans Expressions and Selection, Booleans Expressions and Iteration, Truth Tables Characters, Strings, Length, Concatenation, Upper, Lower, Traversing Strings Python If, Elif, Else conditionals; Nested Selection Statements Python For, While loops with Range, with List Combining loops with conditionals to Break, Continue Procedural Abstraction, Python Def procedures, Parameters, Return Values (edited)

Unit 2

  • bits: the single unit of information in a computer, typically represented as a 0 or 1
  • bytes: grouping of 8 bits
  • hexadecimal/nibbles: numbering system with base 16
  • binary numbers
    • unsigted integer: whole numbers) but have the property that they don't have a + or - sign associated with them. Thus they are always non-negative (zero or positive).
    • signed integer: A signed integer is a 32-bit datum that encodes an integer in the range [-2147483648 to 2147483647]
    • floating point: arithmetic that represents real numbers approximately, using an integer with a fixed precision, called the significand
  • Binary Data Abstractions
    • Boolean: a value that is either true or false (1 or 0)
    • ASCII: a character encoding standard for electronic communication; diff symbols stand for different numbers; used 1 byte
    • Unicode: Unicode is a universal character encoding standard. This standard includes roughly 100000 characters to represent characters of different languages; used 4 bytes
    • RGB: color model based on red value, green value, and blue value.
  • Data Compression:
    • Lossy: Lossy compression reduces a file by permanently eliminating certain information, especially redundant information. When the file is uncompressed, some of the original information is not there, although the user may not notice it.
    • Lossless: Every bit of data originally in a file remains after it is uncompressed, and all the information is restored.

Unit 3 Algorithm/Programming Terms

  • Variables: A value that can change, depending on conditions or on information passed to the program. A variable can be assigned to a certain integer, float, string...
  • Data Types: a classification that specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error.
  • Assignment Operators: sets and/or re-sets the value stored in the storage location(s) denoted by a variable name; in other words, it copies a value into the variable
  • Managing Complexity with Variables
    • Lists: an abstract data type that represents a finite number of ordered values, where the same value may occur more than once.
    • 2D Lists: 2D array is a collection of data cells, all of the same type, which can be given a single name
    • Dictionaries: an abstract data type that defines an unordered collection of data as a set of key-value pairs -Class: static variable that can be declared anywhere at class level with static
  • Algorithms: a small procedure that solves a recurrent problem
  • Sequence: the order in which statements are executed
  • Selection: a programming construct where a section of code is run only if a condition is met
  • Iteration: when the same procedure is repeated multiple times.
  • Expressions: a combination of values and functions that are combined and interpreted by the compiler to create a new value, as opposed to a “statement” which is just a standalone unit of execution and doesn't return anything
  • Comparison Operators: >, <=, <, =>, ==... operators that compare
  • Truth Tables: A truth table is a way of summarising and checking the logic of a circuit. The table shows all possible combinations of inputs and, for each combination, the output that the circuit will produce.
  • Characters: a display unit of information equivalent to one alphabetic letter or symbo (char)
  • Strings: A string is generally considered a data type and is often implemented as an array data structure of bytes (or words) that stores a sequence of elements, typically characters, using some character encoding.
  • Length: of a string
  • Concatenation: combining 2 strings
  • Traversing Strings: accessing all the elements of the string one after the other by using the subscript
  • Python If: a statement with an if condition
  • Elif: else if statement, - if x is true then _, else do __
  • Else conditionals: a statement with an else condition-- if x else
  • Nested Selection Statements: selection statements that are nested within themselves (see example) P- ython For While loops with Range: a for/while loop that uses the range() function
  • Python for/while loop with with List: a while/for loop that iterates through a list and applies a certain algo to items in list
  • Combining loops with conditionals to Break: For certain conditions, the loop will terminate exectution
  • Python Def procedures (see code block 1)
  • Parameters: values that are passed through a function
  • Return Values: a value that a function returns to the calling script or function when it completes its task
anumberyay = 25
stringvariable = "i am so sleepy"
numberlist = [1, 2, 3, 4, 5]
listofstrings = ["red", "orange", "yellow", "green", "blue"]
iamnotstressed = False

print(anumberyay)
print(stringvariable)
print(numberlist)
print(listofstrings)
print(iamnotstressed)
25
i am so sleepy
[1, 2, 3, 4, 5]
['red', 'orange', 'yellow', 'green', 'blue']
False
Boolean(w > q) //true
Boolean(w < q)  //false
# list
# sequence: code is run line by line: first remainder of x is found, then statement is printed
# paramenters: the values in the list
numlist = ["3","4","9","76","891"]
for x in numlist:
    if int(x) % 3 == 0:
        print(str(x) + " is divisible by 3 :) ")
        continue
    else:
        print(str(x) + " is not divisible by 3 :(")
        continue
3 is divisible by 3 :) 
4 is not divisible by 3 :(
9 is divisible by 3 :) 
76 is not divisible by 3 :(
891 is divisible by 3 :) 
# list: square brackets

list = []
list.append("flowers")
list.append("fruits")  # appending a value to a defined list
print(list)
['flowers', 'fruits']
mydictionary = {"dogies":"animals"}  # defining dictionary using curly brackets
mydictionary["banana"] = "fruit"   #add keys and values to a dict by setting a value equal to a key, like shown
mydictionary["couch"] = "furniture"  #editing a value inside the dictionary
print(mydictionary)
{'dogies': 'animals', 'banana': 'fruit', 'couch': 'furniture'}
value1 = 5
value2 = value1 / 10 #step 1
value3 = value2 * 2 #step 2
value4 = value3 - 4  #step 3
print(value4)
-3.0
# math functions
number = 5  #defining the variable number
x = number * 2  #defining a variable by using another variable
print(number*2)  # multiplying a variable by 2
print(x)
10
10
#substring = string[start:end] 
#the substring will have the characters including the index "start" to the character BEFORE the index "end"
#len(string) will print the length of string

(string) = "hellobye"
print(string[0:5])
print(string[5:8])
print(string[0:8])
len(string)
hello
bye
hellobye
8
string1 = "butter"
string2 = "fly"
string3 = string1 + string2
print(string3)
butterfly
names = ["cat","dog","racoon","rabbit"]

def length(names):
    for x in names:
        print(x, len(str(x)))

length(names)
cat 3
dog 3
racoon 6
rabbit 6
decimal = int(input("Enter the number you would like to convert into binary")) #get input from user & set variables
binary = 0
i = 0   #set initial
num = decimal

while(num > 0):
    binary = ((num%2)*(10**i)) + binary # set binary equal to remainder of the input/2, multiplied by 10^i
    num = int(num/2) #now number equal num/2 rounded to an integer
    i += 1 #incriment by 1

#output result       
print("Your number " + str(decimal) + " in binary is " + str(binary))
Your number 2133 in binary is 100001010101
feeling = int(input("On a scale of 1-10, how do you feel today (10=amazing, 1= terrible)?"))

def response(feeling):
    if feeling > 8:
        print("Yay! I'm glad you feel that way :)")
        if feeling == 10:
            print("I am so happy for you!")
    else:
        if feeling < 4:
            print("Oh no, I hope you feel better soon! You are doing amazing!")
        else:
            print("You got this, you are doing so well!")

response(feeling)
You got this, you are doing so well!