Unit 3 Sections 5-7 Notes
This blog includes notes that I took from the lessons for sections 5-7.
Unit 3.5 Boolean Expressions
Boolean Operators
- Boolean is similar to binary since it has two possible values. The only difference is that in Boolean, True is 1 and False is 0
Relational Operators
- Relational Operators can work between any two values of the same type known as operands, provided that the type supports such types of operators
- Some of these operators include…
- == (equal to)
- != (not equal to)
-
(greater than)
- < (less than)
-
= (greater than or equal to)
- <= (less than or equal to)
- Work on strings and lists too, values at each index is compared in order to determine which one is greater (ex. abg < acd)
Logical Operators
- Operators that works operand(s) to produce a single boolean result. (ex. and, or, not)
- “and” only returns true when both operands around it are true
- “or” returns true when at least one of its operands is true
- “not” returns true when the boolean after it is false
Unit 3.6 Conditionals
Key Vocab
- algorithm - a set of instructions that are designed to accomplish a certain task
- selection - the process that determines which parts of an algorithm is being executed based on a condition that is true or false
Conditionals
- A conditional is a statement that affects the flow/outcome of a program by executing different statements based on the result of a true or false statement (boolean expression!)
- Conditionals appear in almost every programming language because of how important it is for changing the flow of the program
- Conditional statements are used by the selection process for a program
- One example of a conditional is an if/else statement. If/else statements are used in almost every programming language
Unit 3.7
Nested Conditional Statements
- Nested Conditional Statements consist of conditional statements within conditional statements
- Essentially, one can think of nested conditional statements as an if statement within an if statement.
- If Else statements can be put inside of another if else statement