Unit 3 Vocab
Unit 2… Binary/Data Terms
- Bits, Bytes, Hexadecimal / Nibbles
- binary digit that is the smallest increment of data on a computer
- ex. 0 and 1
- a byte is 8 bits
- ex. 12,345,678
- Hexadecimal is a base/positional number system used in mathematics and computer science (base 16 numbering system)
- a nibble is 4 bits
- binary digit that is the smallest increment of data on a computer
- Binary Numbers: Unsigned Integer, Signed Integer, Floating Point
- a binary digit, or bit, is the smallest unit of data
- unsigned: integers that don't have a sign associated with them
- ex. 1, 2
- signed: A signed integer is a 32-bit datum that encodes an integer in the range [-2147483648 to 2147483647]
- -100, 80
- Floating point: a positive or negative whole number with a decimal point
- ex. 5.5
- ex. 5.5
- unsigned: integers that don't have a sign associated with them
- a binary digit, or bit, is the smallest unit of data
- Binary Data Abstractions: Boolean, ASCII, Unicode, RGB
- Boolean: datatype that does true or false
- ASCII: a character encoding scheme in which each character is represented by a 7-bit (originally) or 8-bit binary sequence
- Unicode: 16-bit character set which describes all of the keyboard characters
- more than ASCII
- ex. emojis
- RGB: a problem solving approach (algorithm) to find a satisfactory solution where finding an optimal or exact solution is impractical or impossible
- example.
- Data Compression: Lossy, Lossless
- Lossy: data encoding and compression technique that deliberately discards some data in the compression process
- Lossless: data compression algorithm that allows the original data to be perfectly reconstructed from the compressed data
- Lossy: data encoding and compression technique that deliberately discards some data in the compression process
x = True
y = False
Unit 3… Algorithm/Programming Terms
-
Variables, Data Types, Assignment Operators
- Variables: a value that can change, depending on conditions or on information passed to the program
- Data Types:
- String (or str or text) - combination of any characters
- Character (or char) - single letters
- Integer (or int) - whole numbers
- Float (or Real) - numbers that contain decimal points, or for fractions.
- Boolean (or bool) - data is restricted to True/False or yes/no options
- Assignment Operators: operator used to assign a new value to a variable
- ex. =, +=, -=
-
Managing Complexity with Variables: Lists, 2D Lists, Dictionaries, Class
- Lists: an abstract data type that represents a finite number of ordered values, where the same value may occur more than once.
- 2D lists: a two-dimensional array can hold more than one set of data
- Dictionaries: an abstract data type that defines an unordered collection of data as a set of key-value pairs
- Class: written in a defined structure to create an object.
-
Algorithms, Sequence, Selection, Iteration
- Algorithms: a list set of instructions, used to solve problems or perform tasks.
- Sequence: algorithms do tasks in the order of specification.
- Selection: helps choose two different outcomes based off a decision.
- Iteration: if a condition is true, then the code can repeat.
- Algorithms: a list set of instructions, used to solve problems or perform tasks.
-
Expressions, Comparison Operators, Booleans Expressions and Selection, Booleans - - - Expressions and Iteration, Truth Tables
- Expressions: combination of values and functions that are combined and interpreted to create a new value.
- x + y Addition
- x - y Subtraction
- x * y Multiplication
- x / y Division
- x // y Quotient
- x % y Remainder
- x ** y Exponentiation
- Comparison Operators: compares two values against one another.
- a = b equal to
- a > b greater than
- a < b less than
- a >= b greater than or equal to
- a <= b less than or equal to
- a != b not equal to
- Boolean Expressions: if a condition is true or false, there is a differnet outcome and if a condition is true, the code repeats an earlier step
- Truth Table:
- have two values
- 0 = off, false
- 1 = on, true
- Examples
- 0 and 0 = false. And operator means both needs to be true.
- 0 or 1 = true. Either or.
- Use this in conditionals (selection)
- XOR = exclusive or.
- Or = similar to true or false
- ex. A is true, B is false
- have two values
- Expressions: combination of values and functions that are combined and interpreted to create a new value.
-
Characters, Strings, Length, Concatenation, Upper, Lower, Traversing Strings
- Characters: display unit of information equivalent to one alphabetic letter or symbol
- ex. a, 8, #
- Strings: ordered sequences of characters
- Length: the number of symbols output.
- Concatenation: String concatenation is combining 2 or more strings to make a new strings in order to create a new string
- concat() in pseudocode and varys from language to language can be used to combine to strings such as concat("cookie","monster") returns cookiemonster
- Upper: used to check if the argument contains any uppercase characters
- returns "True" if all characters in the string are uppercase, Otherwise, It returns "False"
- Lower: returns the lowercase string from the given string
- Traversing Strings: the process of going through a String one character at a time, often using loops
- Characters: display unit of information equivalent to one alphabetic letter or symbol
- Python If, Elif, Else conditionals; Nested Selection Statements
- If: statement executes a piece of code when one statement is false and the following statement is true
- Elif: first if statement isn't true, but want to check for another condition
- Else: executes if "if" isn't true
- Nested Conditionals: when more than one decision must be made before the appropriate action can be taken
- If: statement executes a piece of code when one statement is false and the following statement is true
- Python For, While loops with Range, with List
- For: Process stops if next element meets statement
- While: Process is repeated until statement is met
- While with range:
- While with list:
- Combining loops with conditionals to Break, Continue
- Procedural Abstraction, Python Def procedures, Parameters, Return Values
- python def procedures: Defines an abstracted function
- parameters: A numerical or other measurable factor forming one of a set that defines a system or sets the conditions of its operation.
- return values: The result of a function returned to the caller
x = 3
# x would be the variable
# Datatypes
str = "Claire"
int = 10
bool = True
char = "a"
Real = 4.1222222
# assignment operator is =
# List
numbers = [1, 2, 3, 4]
# 2D List
rows, cols = (5, 5)
# 5 rows and 5 columns
arr = [[0]*cols]*rows
for row in arr:
print(row)
# Dictionaries
import random
# random is the dictionary (outside source)
diceRoll = random.randint(1,6)
# random number from 1 to 6
print(diceRoll)
# Class
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
p1 = Person("Claire", 16)
print(p1.name)
print(p1.age)
# Algorithm: sequence, selction, and iteration
temp = 70
if temp < 50:
print("stay inside")
else:
print("go outside")
# selection using conditionals
petals = 8
while (petals > 0):
print(petals)
petals -= 1
if petals == 0:
print("no more petals")
# iteration using while loop
# Expression
a = 1
b = 2
c = 3
result = (a*b)/c
print(result)
# Comparison Operators
1 != 2
# 1 is not equal to 2, will output true
3 >=4
# 3 is greater than or equal to 4, will output false
# String
print("Hello Everyone")
# Length
length = len("Hello Everyone")
print(length)
# space counts as a character
# Concantation
s1 = 'Hello'
s2 = 'Everyone'
s3 = s1 + s2
print(s3)
# Upper
txt = "Hello Everyone"
x = txt.upper()
print(x)
# Lower
txt = "HELLO EVERYONE"
x = txt.lower()
print(x)
# Tranversing String
string_name = "hello everyone"
# Iterate over the string
for element in string_name:
print(element, end=' ')
print("\n")
# Conditionals
temp = 55
if temp < 50:
print("it's cold")
elif temp > 80:
print("it's hot")
else:
print("good wheather")
# Nested Conditionals
print("Have you watched criminal minds?")
reply1 = input("yes or no?")
if reply1 == "yes":
print("Who's your favorite character")
reply2 = input("favorite character")
if reply2 == "Emily":
print("yay")
else:
print("oh")
else:
print("you should")
# For Loop
members = ["Annika", "Claire", "Grace"]
for x in members:
if x == "Claire":
break
print(x)
# While Loop
i = 1
while i < 6:
print(i)
i += 1
# with range
while i in range(1,2):
print("Claire", i)
# with list
thislist = ["Annika", "Claire", "Grace"]
for i in range(len(thislist)):
print(thislist[i])
# Parameters
import random
flip = random.randint(1,2)
if flip == 1:
print("Heads")
else:
print("Tails")
# Define and Return Procedures
# goal (x+1)(x-2)
x = int(input())
def add(a):
return a + 1
def multiply(a):
return a - 2
def equation(x):
addX = add(x)
multiplyY = multiply(x)
return addX * multiplyY
result = equation(x)
print(result)