Lecture 3 Flashcards
Bool
Variable type. Can be true (1) or false (0). Stored in one bit.
Boolean operations
And (&&), or (||), not (!)
Always enclose boolean expressions in parentheses so there isn’t any odd behavior due to order of operations. Boolean order of operations is not, and, or.
Not (boolean operation)
Flips the bool (false becomes true, true becomes false). ! Is the not operator and comes before whatever it is flipping.
And (boolean operation)
If two conditions are met, it returns true. && is the and operator. Using only one & is known as bitwise, which is not the same thing.
Or (Boolean operator)
Is true if either condition is met. || is the or operator.
Logical Operations
The computer reads not first, then and, then or.
Comparison Operators
Greater than (>), greater than or equal to (>=), less than (<), less than or equal to (<=), equal (==), not equal (!=).
If statement
If statements executes the code that follows if the conditional is met.
Else statement
Executed the code that follows if the conditional is not met.
Else if statment
Executes the code that follows if the statement that follows else if is met and the preceding if statements are not met.
Conditional
Statement that evaluates to true or false. Helps with decision making in code.
Curly braces
Best if they follow any if/then/else statment
Indentation
Helps with organization. Commands are typically indented.