Vocab
Vocab
Unit 2β¦ Binary/Data Terms
Bits: A given byte contains either bits or a code. A designation of 'bits' means that each individual bit has its own meaning, independent of the meaning of other bits in the byte
bits = 8 # 8 bits in a byte
Bytes: a group of binary digits or bits (usually eight) operated on as a unit.
bytes = 1024 # 1 kilobyte
Hexadecimal / Nibbles: In communications, a nibble is sometimes referred to as a quadbit. As with any nibble, the quadbit is 4 bits and has 16 possible combinations.
hex_val = 0xFF # 255 in hexadecimal
nibble_val = 0b1111 # 15 in binary
Binary Numbers: According to digital electronics and mathematics, a binary number is defined as a number that is expressed in the binary system or base 2 numeral system. It describes numeric values by two separate symbols; 1 (one) and 0 (zero)
Unsigned Integer: Unsigned Integers (often called "uints") are just like integers (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)
unsigned_int = 45 # 45 in binary
Signed Integer: positive, negative, whole number, or zero
signed_int = -45 # -45 in binary
Floating Point: A floating point number, is a positive or negative whole number with a decimal point.
float_val = 3.14 # 3.14 in binary
Binary Data Abstractions: Boolean: a binary variable, having two possible values called βtrueβ and βfalse.β
boolean_val = True # True in binary
ASCII: ASCII (American Standard Code for Information Interchange) is the most common character encoding format for text data in computers and on the internet.
ascii_val = ord('A') # 65 in binary
Unicode: an international encoding standard for use with different languages and scripts, by which each letter, digit, or symbol is assigned a unique numeric value that applies across different platforms and programs.
unicode_val = ord('π¨βπ©βπ§βπ¦') # 128103 in binary
RGB: red, green, and blue RGB (red, green, and blue) refers to a system for representing the colors to be used on a computer display.
rgb_val = (255, 0, 0) # 255 red in binary
Data Compression: Data compression is a reduction in the number of bits needed to represent data.
Lossy: involving or causing some loss of data. Lossy compression is a way of getting even smaller squeezed files than lossless.
lossy_val = 0.5 # 50% of data lost
Lossless (not discussed yet)
lossless_val = 0 # 0% of data lost
Unit 3β¦ Algorithm/Programming Terms
-
Variables: A variable is a symbolic name for a value that can be changed, depending on the conditions of a program.
#Variables #Declaring a variable in Python name = "John"
- Data Types: Data types are the classification or categorization of data items. Examples of data types include integers, floating point numbers, characters, strings, and Boolean values.
#Data Types
#Creating an integer
integer_example = 5
#Creating a float
float_example = 3.14
#Creating a Boolean
boolean_example = True
#Creating a string
string_example = "Hello World"
-
Assignment Operators:Assignment operators are used to assign a value to a variable. Examples include the =, +=, -=, *=, and /= operators.
#Assignment Operators #Assigning the value of a variable x = 5 #Adding to a variable x += 5 #Subtracting from a variable x -= 5
-
Lists: A list is an ordered collection of data items. Items in a list are separated by commas and are enclosed in square brackets.
#Managing Complexity with Variables: Lists #Creating a list list_example = [1, 2, 3] #Adding an element to a list list_example.append(4)
-
2D Lists: A two-dimensional list is a list of lists. Each list inside the 2D list is a row, and each item in the row is a column.
#Creating a 2D list list_example_2d = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
-
Dictionaries: A dictionary is a data type that maps keys to values. Items in a dictionary are separated by commas and are enclosed in curly braces.
#Creating a dictionary dict_example = {'name': 'John', 'age': 29}
-
Classes: A class is a code template that is used to create objects. It is a blueprint of an object and is used to define the properties and methods of an object.
#Creating a class class Car: def __init__(self, make, model): self.make = make self.model = model
-
Algorithms: An algorithm is a set of instructions or steps used to solve a problem.
#Creating a sequence sequence_example = [1, 2, 3, 4, 5]
-
Sequence: A sequence is a set of instructions that are performed in the same order.
#Creating a sequence sequence_example = [1, 2, 3, 4, 5]
-
Selection: Selection is a process of choosing an appropriate path or action based on a given condition.
#Creating a selection selection_example = [i for i in sequence_example if i % 2 == 0]
-
Iteration: Iteration is the process of repeating a sequence of instructions until a certain condition is met.
#Creating an iteration for i in sequence_example: print(i)
-
Expressions: An expression is a combination of values, variables, and operators that evaluates to a single value.
-
Comparison Operators: Comparison operators are used to compare two values. Examples include the >, <, ==, and != operators.
#Creating a comparison operator x = 5 y = 6 x_less_than_y = x < y
-
Booleans Expressions and Selection: Boolean expressions are expressions that evaluate to either true or false. They are used to control selection statements.
#Creating a Boolean expression my_bool = True
-
Booleans Expressions and Iteration: Boolean expressions are used to control looping statements such as while and for loops.
-
Truth Tables: A truth table is a table that shows the truth values of a logical expression.
#Creating a truth table truth_table = { True: 'Yes', False: 'No' }
-
Characters: A character is a single letter, number, or symbol.
-
Strings: A string is a sequence of characters.
#Creating a string string_example = "Hello World"
-
Length: The length of a string is the number of characters it contains.
#Calculating the length of a string string_example_length = len(string_example)
-
Concatenation: Concatenation is the process of combining two strings together to form a single string.
#Concatenating two strings concatenated_string = string_example + "!"
-
Upper: Upper is a method that converts all the characters of a string to uppercase.
#Changing a string to upper case upper_string = string_example.upper()
-
Lower: Lower is a method that converts all the characters of a string to lowercase.
#Changing a string to lower case lower_string = string_example.lower()
-
Traversing Strings: Traversing a string means to access each character of the string in sequence.
#Traversing a string for char in string_example: print(char)
-
Python If, Elif, Else conditionals: Python If, Elif and Else statements are used to control the flow of the program based on a certain condition.
#Creating a simple if statement if x < 10: print("x is less than 10")
-
Nested Selection Statements: Nested selection statements are selection statements that are nested inside of other selection statements.
#Creating a nested selection statement if x > 5: if x < 10: print("x is between 5 and 10")
-
Python For, While loops with Range: Python For, While loops with Range: The Python For and While loops are used to iterate over a range of values.
#Creating a for loop with a range for i in range(10): print(i)
-
Python For, While loops with List: The Python For and While loops are used to iterate over a list of values.
#Creating a for loop with a list for item in list_example: print(item)
- Combining loops with conditionals to Break, Continue: Combining loops with conditionals can be used to break out of a loop or continue to the next iteration of the loop. ```python #Creating a for loop with a break for i in range(10): if i == 5: break print(i)
Creating a for loop with a continue
for i in range(10): if i == 5: continue print(i)
29. <mark>Procedural Abstraction:</mark> Procedural abstraction is the process of breaking a problem down into smaller, more manageable parts.
```python
def add_
-
Python Def procedures: A Python Def procedure is a function that is defined using the Python Def keyword.
-
Parameters: Parameters are the variables that are passed to a function.
-
Return Values: Return values are the values that a function returns once it has been executed.
- Procedural Abstraction, Python Def procedures, Parameters, Return