Chapter 7 Decision Structures Flashcards

1
Q

decision structures

A

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.

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

What does an “if” statement do and how is it formatted?

A

it is used to implement the decision
if <condition>:
<body></condition>

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

What are relational operators? give a few examples

A

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

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

what are module files that are meant to run directly?

A

programs or scripts

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

what are modules designed primarily to be imported and used by other programs?

A

Libraries

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

what is an if-else statment?

A

a two way decision that can be implemented by attaching an else clause onto an if
if<condition>:
<statement
else:
<statemnent></statemnent></condition>

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

What is exception handling?

A

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.

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

what does exception handling look like?

A

try:

<body>
except <error>:
<handler>
</handler></error></body>

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

The math.sqrt function cannot compute the square root of a negative number.

A

true

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

The condition x <= y <= z is not allowed in Python.

A

False

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

The best structure for implementing a multi-way decision in Python is:

A

if-elif-else

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

In Python, the body of a decision is indicated by

A

indentation

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

Briefly discuss the concept of lexicographic ordering.

A

Ack WHAT IS IT

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