Booleans and IFs Flashcards

1
Q

What are the different types of control structures?

A

Sequences, Choice, and Repetition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a boolean

A

Used for true/false values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a boolean expression?

A

A boolean variable, or an expression that gives a boolean result

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the built-in boolean values that respond to user input?

A

mousePressed and keyPressed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can you invert booleans?

A

With an exclamation point

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are relational operators?

A

==, <, <=, !=, >, >=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are boolean operators?

A

&&, ||, !

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the order of operations now?

A
  • expressions in parentheses
  • Unary operators: +, -, ++, –, !
  • Multiplicative: * / %
  • Additive: +, -
  • Relational: >, <, >=, <=
  • Equality: ==, !=
  • Logical and: &&
  • Logical or: ||
  • Assignment: =, +=, -=, *=, /=, %=
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is short-circuiting?

A

If a condition is met, no further conditions will be tested in the if-else-if chain, or a test will be stopped as soon as the answer is known

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Why is it sometimes difficult to tell if two floating-point numbers are equal?

A

Because they are approximations. Errors accumulate as you do operations, so it is better to use >= and\or <= instead

How well did you know this?
1
Not at all
2
3
4
5
Perfectly