Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
3 Cards in this Set
- Front
- Back
! (logical NOT)
|
Inverts the Boolean value of an expression. Returns true if the expression is false and returns false if the expression is true. If the expression (a>b) evaluates to true, then !(a>b) evaluates to false.
Example boolean a = false; if (!a) { rect(30, 20, 50, 50); } a = true; if (a) { line(20, 10, 90, 80); line(20, 80, 90, 10); } Syntax !expression |
|
&& (logical AND)
|
Compares two expressions and returns true only if both evaluate to true. Returns false if one or both evaluate to false. The following list shows all possible combinations:
true && false // Evaluates false because the second is false false && true // Evaluates false because the first is false true && true // Evaluates true because both are true false && false // Evaluates false because both are false Example for (int i = 5; i <= 95; i += 5) { if ((i > 35) && (i < 60)) { stroke(0); // Set color to black } else { stroke(255); // Set color to white } line(30, i, 80, i); } Syntax expression1 && expression2 |
|
|| (logical OR)
|
Compares two expressions and returns true if one or both evaluate to true. Returns false only if both expressions are false. The following list shows all possible combinations:
true || false // Evaluates true because the first is true false || true // Evaluates true because the second is true true || true // Evaluates true because both are true false || false // Evaluates false because both are false Example for (int i = 5 ; i <= 95; i += 5) { if ((i < 35) || (i > 60)) { line(30, i, 80, i); } } Syntax expression1 || expression2 |