Upgrade to remove ads
ITC-106 Week 3 - Decision Structures and Boolean Logic
Terms in this set (12)
A logical design that controls the order in which a set of statements execute
What is a Control Structure?
Set of statements that execute in the order they appear
What is a Sequence Structure
A specific action is performed only if a certain condition exists
What is a Decision Structure?
sales = float(input('Please enter your total sales for the month: '))
if sales >= 10000:
commissionRate = 0.2
commission = sales * commissionRate
print('You earned $ ', format(commission, ',.2f'), 'this month')
Write an if statement that assigns 0.2 to commissionRate if sales is greater than or equal to 10000. Calculate and print the commission that is earnt if this is True
If the expression on the left side evaluates to False the expression on the right is not checked
How does Short Circuit evaluation work with the and operator?
If the expression on the left side evaluates to True the expression on the right is not checked
How does Short Circuit evaluation work with the or operator?
if not (temperature > 22):
print('This is below the maximum temperature.')
Use the not operator to write an if expression that checks if the temperature is below 22 degrees
1) The expression is evaluated to either True or False
2) Not is then applied to this and the values reversed
Describe how the logic of using the not operator in an if statement works
And - all expressions must evaluate to True
Or - any expression needs to evaluate to True
What is the difference between the and and or logical operators?
No - x cannot both be less than 20 and greater than 40 at the same time
Is the below a valid compound Boolean expression?
if x < 20 and x > 40:
print('The value is outside the acceptable range.')
True or False
What values can a Boolean variable reference?
A variable that signals when some condition exists, the condition may be:
True - the condition exists
or False - the condition does not exist
What is a flag variable?
THIS SET IS OFTEN IN FOLDERS WITH...
ICT - 106 Chapter 2 - Week 2 Input, Processing, Ou…
ITC-106 Ch10 - Object Oriented Programming
YOU MIGHT ALSO LIKE...
CS1336 Chapter 4
Starting Out With Python Chapter 3
Java Chapter 4
OTHER SETS BY THIS CREATOR
ITC333 - Wk11 - Security, troubleshooting & perfor…
ITC333 - Wk10 - Configuring Network Services and C…
ITC333 - Wk9 - Network Configuration
ITC-333 Wk 8 - Chapter 9 - Managing Linux Processes