Binary/Data and Algorithm Study Guide
This is my binary/data and algorithm study guide
Binary/Data Vocab
- Bits: The smallest unit of data that a computer can process and store. A bit is always in one of two physical states, similar to an on/off light switch. The state is represented by a single binary value, usually a 0 or 1.
- Bytes: A byte is a unit of data that is eight binary digits long. A byte is the unit most computers use to represent a character such as a letter, number or typographic symbol. 00000000 - 11111111
- Hexadecimal: a numbering system w/ base 16. It can be used to represent large numbers with fewer digits. In this system there are 16 symbols or possible digit values from 0 to 9, followed by six alphabetic characters – A, B, C, D, E and F. It can be used for colors, ex. #FCD0E0
- Boolean: a true/false value
c = 10 > 5
print(c)
a = "pink"
b = "purple"
a == b
ASCII: most common character encoding format for text data in computers and on the internet
Unicode: the universal character representation standard for text in computer processing.
RGB: (red, green, and blue) refers to a system for representing the colors to be used on a computer display.
Lossy: Lossy is a data encoding and compression technique that deliberately discards some data in the compression process
Lossless: restores and rebuilds file data in its original form after the file is decompressed
x = "Alex"
print(x)
The three data types are integers, strings, and booleans. The best data type to represent someone's dog's name is a string. The best data type to represent someone's phone number is an integer.
name = "Timmy"
age = "25"
print(name + " is " + age)
lists: abstract data type that represents a finite number of ordered values
dictionaries: an abstract data type that defines an unordered collection of data as a set of key-value pairs
classList = ["Expos 2", "Bio 1", "Chamber Choir", "APCSP", "AP Stats"] # list
classDic = ["period4": "APCSP", "period5": "AP Stats"] # dictionary
- assignment operators:
- addition: a + b
- subtraction: a - b
- multiplication: a * b
- division: a / b
- MOD: a % b
num1 = 12
num2 = 25
num3 = 14
result = num1 / 4 * num3 + 9 % 2 - num3
print(result)
algorithm: commands that do a certain task
sequence: the order in which the statements are executed
selection: a section of code is run only if a condition is met.
iteration: a repeating portion of an algorithm, repeats a specified number of times or until a given condition is met
for i in range(1,11):
print(i)
truth tables
- AND: 1 1
- OR: 0 1, 1 0, 1 1
- XOR: 0 0, 1 1
NOT: 0
length: number of characters in a string
concatenation: combining two things
upper/Lower: change case
traversing Strings: use index
if: do an action when something is true
elif: first condition false, test another
else: action when first condition false
nested selection: condition inside condition
import random
colorspinner = random.randint(1,8)
if colorspinner <= 3:
print("green")
elif colorspinner <= 5:
print("blue")
elif colorspinner <= 6:
print("purple")
elif colorspinner <= 7:
print("red")
else:
print("orange")
tasks = ["review notes", "do practice problems", "ask teacher questions"]
for task in tasks:
print(task)
def: defining a function to do a procedure
parameters: values given to a function to work with
return: brings variables out of function after running
def birthday_funct():
print(" My birthday is October 29th")
birthday_funct()