Chapter 3 checkpoint questions Flashcards
What is a control structure?
A logical design that controls the order in which a set of statements execute.
What is a decision structure?
It is a program structure that can execute a set of statements only under certain circumstances.
What is a single alternative decision structure?
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.
What is a Boolean expression?
An expression that can be evaluated as either true or false.
Write an if statement that assigns 0 to x if y is equal to 20.
if y == 20:
x = 0
Write an if statement that assigns 0.2 to commissionRate if sales is greater than or equal to 10000.
if sales >= 10000:
commissionRate = 0.2
What would the following code display?
if ‘z’ < ‘a’:
print(‘z is less than a.’)
else:
print(‘z is not less than a.’)
z is not less than a.
What would the following code display?
s1 = 'New York' s2 = 'Boston'
if s1 > s2: print(s2) print(s1) else: print(s1) print(s2)
Boston
New York