Chapter 7 Decision Structures Flashcards
decision structures
statements that allows a program to execute different sequences of instructions for different cases. This allows the program to “choose” the appropriate course of action.
What does an “if” statement do and how is it formatted?
it is used to implement the decision
if <condition>:
<body></condition>
What are relational operators? give a few examples
it is a fancy name for the mathematical concepts like less than or equal to.
<-less than
<=-Less than or equal to
==- equal to
>- greater than
>=- greater than or equal to
!=- not equal t0
what are module files that are meant to run directly?
programs or scripts
what are modules designed primarily to be imported and used by other programs?
Libraries
what is an if-else statment?
a two way decision that can be implemented by attaching an else clause onto an if
if<condition>:
<statement
else:
<statemnent></statemnent></condition>
What is exception handling?
the idea is that using an exception handling mechanism allows the programmer to write code that catches and deals with errors that arise when the program is run.
what does exception handling look like?
try:
<body>
except <error>:
<handler>
</handler></error></body>
The math.sqrt function cannot compute the square root of a negative number.
true
The condition x <= y <= z is not allowed in Python.
False
The best structure for implementing a multi-way decision in Python is:
if-elif-else
In Python, the body of a decision is indicated by
indentation
Briefly discuss the concept of lexicographic ordering.
Ack WHAT IS IT