3.5 - 3.7 notes
This post is regarding the 3rd student led lesson. 3.5 - 3.7 CB topics. Contains hacks
Booleans:
- expressions that are either true or false
-
can be used to evaluate true or false scenarios
- such as: 2 + 2 is 4 => true
-
# Supplementary questions:
How is binary related to this?
-
Booleans can have 1 (true) or 0 (false) to represent a wide range of data. Binary uses 1's and 0's to represent the number/alphabet system in a computer efficient way.
How could this be used when asked a question?
- you can use booleans when asked a question that can be adequately answered with a yes or no / true or false
-
Logical operators
- Selection: basically selecting which part of an algorithm to execute based on an input or other parameter
- Algorithm: set of procedures that is created to solve a specific problem (problem can be anything; problem doesn't need to be a critical one)
- Conditional statement: instructs the code to make a decision based on a true or false condition
Nested Conditionals
- Nested conditional statements consist of conditional statements within conditional statements
- they're nested one inside the other
- 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