Chapter 3 checkpoint questions Flashcards

1
Q

What is a control structure?

A

A logical design that controls the order in which a set of statements execute.

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

What is a decision structure?

A

It is a program structure that can execute a set of statements only under certain circumstances.

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

What is a single alternative decision structure?

A

A decision structure that provides a single alternative path of execution. If the condition that is being tested is true, the program takes the alternative path.

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

What is a Boolean expression?

A

An expression that can be evaluated as either true or false.

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

Write an if statement that assigns 0 to x if y is equal to 20.

A

if y == 20:

x = 0

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

Write an if statement that assigns 0.2 to commissionRate if sales is greater than or equal to 10000.

A

if sales >= 10000:

commissionRate = 0.2

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

What would the following code display?

if ‘z’ < ‘a’:
print(‘z is less than a.’)
else:
print(‘z is not less than a.’)

A

z is not less than a.

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

What would the following code display?

s1 = 'New York'
s2 = 'Boston'
if s1 > s2:
   print(s2)
   print(s1)
else: 
   print(s1)
   print(s2)
A

Boston

New York

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