Student Teaching Vocab
Markdown post of the group lesson for 3.17-3.18
- Unfamiliar Vocab We Have Covered in Lessons
- OOP
Add on to this throughout the Tri
Unfamiliar Vocab We Have Covered in Lessons
- Managing complexity, algorithms, sequencing, selection, iteration, Booleans, If Elif and Else Conditionals, Nested Conditionals, For and While loops, procedures, libraries, randomization, simulation, undecidability, unsolvability.
Managing Complexity in Lists
- Assinging lists to one variable rather than a different variable per value. As shown here in this example I coded:
Alorithms
- A set of instructions that are followed in order to accomplish a task
- Example of an algorithm below:
Sequencing and Selection
- Sequencing is the order of how you do something
- Like the instructions of a teacher and howo you follow them
- It was 1-5 on the image
- Selection Allows the algorithm to make a decision based on if a condition is met
- Go to the gas station if your tank is empty, dont if its full.
- example of both:
Iteration
- A repeating portion of an algorithm that repeats a certain amount of times until a condition is met
- Example of iteration:
If Elif and Else Conditionals
- Conditional statements that make decisions for you that excecute based on the given conditions.
- Example of all 3:
Nested Conditionals
- Conditional statments within a conditional statement
- example: an else if inside of another else-if\
- Can be used for a varying amount of “else if statements.” The first if statement can represent if two coditions are true. The first else if can represent if only one or the other is true. The last else if represents if neither of the conditions are true.
- Can have three different conditions
Loops
For Loops
- Used for definite loops with a finite number of iterations. Used for when you know exactly the amount of times you want it to repeat.
While Loops
- Used for loops with an infinite/unknown number of iterations. Runs until a condition is met.
Procudeures
- Parameters store variables and arguments
-
Call functions with procedure names (syntax in javascript and python)
- Procedure name: the name that was given to a function
- Arguments provied info to a functio and are usually defined outside of the function then imported into a function with parameters.
Calling Procedures
- You call a procedure by putting the name of ot follwed by paranthesis with the parameters.
- Ex: def math(x)
Managing Complexity
Modularity
- the practice of breaking a complex program into smaller, independent parts or modules that can be used and reused in different parts of the program
- Ex: assert “hypotenuse(3, 4) == hypotenuse_abstracted(3, 4) == 5”
- They would have the same result.
- They would have the same result.
- Ex: assert “hypotenuse(3, 4) == hypotenuse_abstracted(3, 4) == 5”
- the practice of hiding the details of how a particular code or system works and exposing only the essential features or functions that are necessary for other parts of the program to use
- having multiple duplicate code blocks, often decreasing readability and efficiency
- the sequence of steps and operations that a computer follows to execute a program, including the specific instructions and decision-making processes built into the code
Libraries and Randomization
Library
- Library: collection of code from an external source that adds functions and assets to a program
- Are called using a special keyword, Import
-
To install a library, you can use “pip install _____” which is the name of the library.
- Example: Math Library:
Randomization
- “Import random” randomizes options that are inputted between parenthesis ().
Simulations
Simulation vs Experiment
Simulation Advantages
- Can be safer
- More cost-effective
- More efficient
- More data in less time
- Not as accurate as experiments
- outside factors not included (ex: in rolling dice simulation gravity and air resistance)
- when a situation already has set results/data (won’t change)
- examples: a score in a game, most purchased food, average yearly wage
Undecidability vs Unsolvability
- Unsolvable: is that no algorithm can be written to get the answer to it
- Undecidable: There is no code that can find the answer, because it is too complext, but there is an answer.
OOP
Init attribute
- “init” is short for initialization
- the process of setting up the environment or initial state of a program or system before it begins to execute.
- In object-oriented programming, it often refers to the constructor method of a class, which is called when a new instance of the class is created, and is responsible for setting up the initial state of the object.
- In other contexts, an “init” function or script is used to set up a specific environment or configuration for a program to run.
Self Attribute
- When a method is called on an object, the first argument passed to the method is the object itself.
- The convention in Python (and many other programming languages) is to use the name self to refer to this object
Setter
- a method that is used to set the value of a property or variable of an object.
- It’s often used in conjunction with a “getter” method, which is used to retrieve the value of the property or variable.
- The setter method typically takes a single argument, which is the new value to be assigned to the property or variable.
- may also include additional logic, such as validation or other processing that should be performed when the value of the property or variable is changed
Getter
- a method that is used to retrieve the value of a property or variable of an object.
- It’s often used in conjunction with a “setter” method, which is used to set the value of the property or variable.
- typically takes no arguments and returns the current value of the property or variable.
- It’s often used to provide read access to the internal state of an object, while keeping the internal state hidden from the outside world
- Getters and Setters are also called accessors and mutators respectively.