Chapter 3: Conditionals Flashcards
The sequence of statements within a compound statement.
body
An expression whose value is either True or False.
boolean expression
One of the alternative sequences of statements in a conditional statement.
branch
A conditional statement with a series of alternative branches (more than two)
chained conditional
One of the operators that compares its operands: ==, !=, >, <, >=, and <=.
Nonzero numbers are TRUE
comparison operator /
relational operator
A statement that controls the flow of execution depending on some condition.
conditional statement
The boolean expression in a statement that determines which branch is executed.
condition
A statement that consists of a header and a body. The header ends with a colon (:). The body is indented relative to the header.
compound statement
Where we construct a logical expression with additional comparisons to take advantage of the short-circuit behavior and avoid errors
guardian pattern
One of the operators that combines boolean expressions: and, or, and not.
logical operator
A conditional statement that appears in one of the branches of another conditional statement.
nested conditional
A list of the functions that are executing, printed when an exception occurs.
traceback
When Python is part-way through evaluating a logical expression and stops the evaluation because Python knows the final value for the expression without needing to evaluate the rest of the expression.
short circuit
Boolean order of priority
or
and
not
OR operator
Short-circuit operator, so it only evaluates the second argument if the first one is FALSE.
AND operator
Short-circuit operator, so it only evaluates the second argument if
the first one is TRUE
NOT operator
Has a lower priority than non-Boolean operators, so not a == b is interpreted as not (a == b), and a == not b is a syntax error.
ZeroDivisionError
error when you try to divide by zero
pass
used in a function where you have a header but no body
interactive mode print format
need a space between block statement and print statement
alternative execution
IF-THEN-ELSE logic
try/except
try:
desired code
except:
jumps here is desired code causes and error
eg. “Enter valid input”