Algorithim: A set of commands that runs a certain piece of code repetively

sum = 0 # start with a sum of 0
for i in range (1, 6): # you will repeat the process five times for integers 1-5
    sum = sum + i # add the number to your sum
print(sum)
15

Binary Search- Search procedure which searches the median to find a desired number

List- List of different elements in one item

my_list = [1, "Hello", 3.4]

Array- Multiple data points as one part

cars = ["Ford", "Volvo", "BMW"]

Boolean- True or false value which fullfills a certain variable

sunny = "false"
fun = "true"
print(sunny)
print(fun)
false
true

Nested Conditionals - Multiple conditional loops put inside of each other, so one loop will only run if the other loops condition is fullfilled

var = 3
if var % 2 == 1:
    if var == 3:
        print("Hello")
Hello

Variables - a symbolic name that is a reference or pointer to an object Link:https://realpython.com/python-variables/#:~:text=A%20Python%20variable%20is%20a,the%20object%20by%20that%20name.

Data Types - is 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.

var = 300
bar = int(300.5)
star = float(300)
tar = str(30000)

print(var)
print(bar)
print(star)
print(tar)
300
300
300.0
30000

Simulation- run on a single computer, or a network of computers, to reproduce behavior of a system. Link: https://www.codingame.com/learn/simulation#:~:text=A%20computer%20simulation%20is%20a,and%20take%20the%20best%20decision.

import random
#Asks for user input about how many dice rolls they want
n = int(input("How many dice rolls?"))
#Function roll
def roll(n):
    #Cycles through how many rolls they want
    for i in range (n):
        #Rolls the dice (getting a random number between 1 and 6)
        x = random.randint(1,6)
        #prints the roll of the dice
        print("Your dice roll is", x)
roll(n)

Procedural abstraction - when we write code sections (called "procedures" or in Java, "static methods") which are generalised by having variable parameters. The idea is that we have code which can cope with a variety of different situations, depending on how its parameters are set when it is called Link: http://www.eecs.qmul.ac.uk/~mmh/AMCM048/abstraction/procedural.html#:~:text=Procedural%20abstraction%20is%20when%20we,set%20when%20it%20is%20called.

Efficiency

  • Polynomial: Work is proportional to time(1:1)
  • Exponential: Time is exponential to work rate(2:1)
import time
numlist = [1,3,5,7,9,11,13,15,17,19]
valuelist = [0,3,6,9,12,15,18,21]
def isvalue(value,array):
    #--------------------
    exists = False
    while exists == False:
        for i in range(len(array)):
            if value == array[i]:
                exists = True
        if exists == False:
            return exists
    
    #--------------------

starttime = time.time()
for i in range(100000):
    for i in range(len(valuelist)):
        x = isvalue(valuelist[i],numlist)
endtime = time.time()
print(endtime-starttime,'seconds') 
1.2090861797332764 seconds

Random Function in Python - Function that can be used to choose an item from a type of data set randomly

import random

print(random.randint(0,9))

list = ["o1", "o2", "o3"]
print(random.choice(list))

string = "Prasith"
print(random.choice(string))


tuple1 = (1, 2, 3, 4, 5)
print(random.choice(tuple1))
2
o1
s
5

Library - A Python library is a collection of related modules. It contains bundles of code that can be used repeatedly in different programs. Source: https://www.geeksforgeeks.org/libraries-in-python/

import math
  
A = 16
print(math.sqrt(A))

# Importing specific items
from math import sqrt, sin

B = 3.14
print(sin(B))
4.0
0.0015926529164868282

Week 2 Vocab: Bits, Bytes, Hexadecimal / Nibbles - Different types of ways numbers are stored including different bases such as 2,8,16 Binary Numbers: Unsigned Integer, Signed Integer, Floating Point- Different types of numbers for example an integer is a whole num but a float is a decimal number Binary Data Abstractions: Boolean, ASCII, Unicode, RGB- Data storage ways for example ASCII is using characters, the rest are different types of data storage.

Week 3 Vocab: Variables, Data Types, Assignment Operators - These methods are all used to set values, datatypes are different types of data types and assignment operators are varaibles that are set to equal other variables Managing Complexity with Variables: Lists, 2D Lists, Dictionaries, Class - These are different ways you can sort your elements and data values. The different use cases are for different types of data which need for a certain python function Algorithms, Sequence, Selection, Iteration- Different ways to run a piece of code multiple times in different aspects of the beatiful language of python. Expressions, Comparison Operators, Booleans Expressions and Selection, Booleans Expressions and Iteration, Truth Tables - True or false values which relate to binary which is related to binary. In binary a 1 is true and a 0 is false. Truth tables are the different functions (XOR, AND etc. ) Characters, Strings, Length, Concatenation, Upper, Lower, Traversing Strings - Ways to maniuplaute strings, concatination is the combination of strings, length prints the lenght of a string(characters), the upper and lower relate to the case of the string. Traversing a string goes from left to right of a string. Python If, Elif, Else conditionals; Nested Selection Statements- These are different python functions that run on a condition. The if statement checks if a statement is true, elif checks if another condition is true and else runs if none of the if statements are true. Nested loops are functions inside of other functions. Python For, While loops with Range, with List - For loop runs a certain amount of times based on the condition, and a while loop runs until the function is true. It would be useful to use a while loop when you want to run a loop many times Combining loops with conditionals to Break, Continue - The break stops the code and continue keeps a code running after a part is satisfied. Procedural Abstraction, Python Def procedures, Parameters, Return Values- You can use def function to define a function that will be run many times and you can continue to keep running it. Parameters are