</table> </html> </div> </div> </div> </div>
Term Notes Example
Variables
Variables Used to store values or information
        
s = "Hello World"
i = 10
b = True
# "s", "i", and "b" are the 3 variables. They all show the different data types. The values are assigned with the assignment operator =.
Data Types Specifics which type of value a variable has. Includes string (characters), integer (numbers), and boolean (true/false).
Assignment Operators The operator that assigns a value to a variable, propert, event, etc. Includes =, or -> in pseudocode.
Managing Complexity with Variables
Lists Stores a finite collection of data items.

numbers = [3, 5, 23, 45]
2D Lists List, but organized as a matrix with a number of rows and columns.

2dlist = [[1,2,3,4], 
          [2,3,4,5],
          [3,4,5,6]] 
Dictionaries General-purpose data structure for storing a group of objects

import random

diceroll = random.randint(1,6)
print(diceroll)
5
Class Template definition of methods and variables, describes one or more objects.
        
class Numbers:
x = 5
        
        
Algorithms
Algorithms A procedure as a list of instructions used to solve problems or perform a task. Examples for selection and iteration are both algorithms and sequences
Sequence An ordered series of actions or events that lead to the next in a predetermined order.
Selection Conditions, allow an algorithm to go down one of two paths depending on if a condition is true or false.

temp = 57

if temp < 60:
    print("it's cold")
else:
    print("go outside")
it's cold
Iteration The repetition of part of an algorithm until a condition is met or for a predetermined number of times.

pretzel = 3
while (pretzel > 0):
    print(pretzel)
    pretzel -= 1
    if pretzel == 0:
        print("All done!")
3
2
1
All done!
Expressions
Expressions A combination of operators, constants and variables

result = a MOD b + (c * d)</code</pre>
        </td>
    </tr>
    
Comparison Operators Compares values and returns true or false. Includes >, <, >=, <=, ===, !===.
4 != 5
True
Boolean Expressions A logical statement that is either true or false. Includes ==, <, >, !=, <=, >=.
        
x = 5
y = 6
x > 6
False
Truth Tables A table representing the output boolean values of a logical expression based on their entries
A B Y
0 0 0
0 1 1
1 0 0
1 1 1
Y = B
Strings
Characters Unit of information equivalent to one alphaetic letter or symbol
'A', '4', '#'
Any of these values are characters
Strings Data type that represents characters, including text rather than numbers.
print("Hi, I'm Annika")
Hi, I'm Annika
Length The amount of characters in a string.

length = len("Hi")
print(length)
2
Concatenation Adding strings together

x = "Hi, "
y = "I'm Annika
z = x + y
print(z) 
Hi, I'm Annika
Upper Converts string to all uppercase letters

text = "Hi, I'm Annika
x = text.upper()
print(x)
HI, I'M ANNIKA
Lower Converts string to all lowercase letters

text = "Hi, I'm Annika
x = text.lower()
print(x)
hi, i'm annika
Traversing Strings Processing every character in a string, usually from left end to right end

x = "Hi"
for word in x: print(word)
H
i
Python Conditionals
If If statements performs a function if a condition is met or a statement is true

temp = 55

if temp < 60:
    print("it's cold")
elif temp > 80:
    print("it's hot")
else:
    print("nice weather")
it's cold
Elif First if statement isn't true, but you want to check for another condition
Else Alternative statement executed if the result of a all previous test condition are false
Nested Selection Statements When more than one decision must be made before carrying out a task. Allows for mult-step decisions
        
if x >= 1 and x <= 10:
    if y >= 1 and y <= 10:
        print(x * y)
    else:
        print("incorrect value")
else: 
    print(x + y)
For Loop Process stops if next element meets statement

fruits = ["apple", "banana", "cherry"]
for x in fruits:
    print(x)</pre></td>
    </tr>
    
While Loop Process is repeated until statement is met

fruits = ["apple", "banana", "cherry"]
for x in fruits:
    print(x)
Procedural Abstraction
Procedural Abstraction The practice of hiding the details of how a code/system works, only exposing essential functions necessary for other parts of the program
        
x = 5
y = 3 
def multiply(x, y): product = x * y return product
answer = multiply(x, y) print("The product of", x, "times", y, "is", answer)
The product of 5 times 3 is 15
# A def function is used as abstraction. x and y are the parameters, and the value is returned with the product.
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