Flow Control Flashcards
What do smart programs use to make decisions on whether to run lines of code or skip them?
Booleans
What does an if statement do?
If statements are lines of code that respond to different situations.
What are the values that decide whether a code block runs or not?
Conditions
How can we distinguish code blocks?
Code blocks will have an indentation of two spaces. Lines with the same indentation belong to the same code block.
What do we call the code that is indented after an if statement?
A code block
What is the maximum number of lines that a code block can have?
As many as we want
Why do we use comparisons with if statements?
To make smarter decisions about running or skipping code
What do we use comparisons with == for in an if statement?
To run or skip coe depending on whether two values are the same
What operator runs an if statement’s code block when two values are different?
!= The inequality operator
How can we avoid rewriting the same comparison multiple times?
We can save its result in a variable and reuse the variable.
What’s the keyword that decides if a code block should run or not?
if
What kind of value do we use as a condition for an if statement?
Boolean
What do we call statements that run or skip code depending on a condition being True or False?
Conditional statements
Why are comparisons better conditions than just True or False?
Because the value of the variables can change, so it may run or skip a code block depending on the value.
Where is an else statement positioned?
The else statement of an if/else statement always goes at the end.