3.3 - 3.4

  • algorithm: A finite set of instructions that accomplishes a task. This can expressed by natural language, diagrams, and various other methods
  • Three parts to an algorithm:
    • Sequencing: The order of how to do something to achieve a result, similarly to how you follow "instructions from a teacher."
    • Selection: Selections allow an algorithm to make a decision based on if a condition is met (fulfilled or confirmed). An example of this would be traveling to a gas station to fill your car,
    • Iteration: An iteration is a loop and continues to loop until the condition if met, like if there was a check for when you put away your computer when you finish your work every five seconds, and will continue to repeat until you finish your work, otherwise meaning that your conditions are met.

Mathematical Expressions

  • Sequential code statement: Sequential statements are used in processes to specify how signals are assigned. The process is executed in order as a whole. After all the sequential statements in the process are executed the signals are assigned their new values. They execute in the order in which they appear in the process.
  • Sequencing: First step to do, then do the second step, then do the third step, all in order.
  • Use algorithms to create mathematical expressions.

Arithmetic operator: languages that use addition, subtraction, multiplications, division, and modulus operator.

Examples of arithmetic operators: 10 + (5 * 8) / 4

  • num1 = 10
  • num2 = 5
  • num3 = 7 result = num1 + num2 + num3 print(result) = answer

3.5 - 3.7

Boolean

  • Boolean: a denoting system of algebraic notation used to represent logical propositions, especially in computing and electronics.
  • Booleans show is something is either true or false
  • Testing if two numbers or variables are equal is a common example. (another example can be that the sky is blue = True/False) There is some testing below to show my understanding of booleans. This can probably be used to compare values in future projects.
x = 3
y = 4

result = bool(x>y)
print(result)
False

Relational Operators

  • Relational Operators: the mathematical relationship between two variables
  • Determines an output on whether or not the statement is true
  • Examples of Relational Operators: =, >, < (Not specific but I think <= and >= are also relational operators)

Logical Operators

  • Not: displays the opposite of whatever the data is. This is mainly used for true/false statements, does NOT affect the variables

  • And: used to evaluate two conditions together and determine if both conditions are met

  • Or: When using "Or" the function only looks to see if one of the conditions is met.

Awake = True
result = not(Awake)
print(result)

# Example of AND

score = 80
if score > 70 and score <= 100:
    print("pass")

# Example of OR

money = 10
time = 30

if money < 5 or time >= 30:
    print("done")
False
pass
done

Learning Objectives:

  • Conditionals alow for the expression of algorithms that utilize selection without a programming language.
  • WRiting conditional statements is key to computer science.
  • Determine the result of conditional statements.

Vocab Terms:

  • Selection: The specific block of code that will execute depending on the algorithm condition returning true or false.
  • Algorithm: "A finite set of instructions that accomplish a specific task."
  • Conditional Statement / If-Statement: A statement that affects the sequence of control by executing certain statements depending on the value of a boolean.

Essential Knowledge (Key Takeaways):

  • Conditional statements ("if" statements) affect the sequential flow of control by executing different statements based on the Boolean expression's value.