Requirements must resolve equality
Below 60 means strictly less than 60. At 60, the rule denies enable. Replacing < with <= changes the requirement, even if most sample readings produce the same answer.
Week 03 / Describe and decide
Make every combination of conditions have a clear outcome.
A display communicates a result. The next step is to make a decision from it. Before choosing a Python branch, we need an operating rule that two people would interpret the same way.
In our simulated motor test, a run request is present. The motor may be enabled only when the guard is closed and the temperature is below 60 °C.
Start with the problem
Decide what the model should do with a closed guard at 59 °C, a closed guard at 60 °C, and an open guard at 25 °C. Give the reason for each decision.
Comparisons express each condition. if/else and and combine them into the written rule. We will check the decision table against the code.
By the end: Explain an ENABLE or DENY result from the rule, including the exact threshold. This exercise models a decision; it does not implement a hardware interlock.
Below 60 means strictly less than 60. At 60, the rule denies enable. Replacing < with <= changes the requirement, even if most sample readings produce the same answer.
Both prerequisites must hold, so use and. With or, a closed guard could permit enable at excessive temperature. A truth table exposes this mistake more clearly than a long program.
The example assumes a Boolean guard signal and a valid numeric temperature. It says nothing about sensor freshness, broken wires, actuator response or certified interlocks. An enable decision in software is not evidence that motion is safe.
Read the example alongside the explanation. Run it in a new notebook cell and change one input to see how it behaves.
guard_closed = True
temperature_c = 60.0
if guard_closed and temperature_c < 60:
print('ENABLE')
else:
print('DENY')DENY
A Boolean expression answers a precise yes/no question. An if/elif chain chooses the first satisfied branch; separate if statements ask separate questions. Translate the operating rule before choosing the syntax.
Draw a temperature number line with the accepted interval 10 ≤ temperature ≤ 40, then a second gate for guard_closed. Operation requires both gates.
Predict before running. Classify temperatures 9, 10, 40 and 41 with a closed guard. What changes when the guard is open?
The condition means “inside the interval AND guard closed.” Using or would allow operation when only one requirement holds. This is a logic exercise, not a complete machine-safety controller.
Change one thing. Change the specification to exclude the upper endpoint. Identify exactly one comparison that must change and one test that detects it.
Türkçe: Önce işletme kuralını ve sınırlarını çiz. and bütün koşulları ister; or yalnızca birinin sağlanmasıyla doğru olabilir.
Each example changes something about the same problem. Open the ones you want to explore and follow the worked explanation.
Guard closed = True; temperature = 59 °C
Question: Enable or deny? Which prerequisites are satisfied?
Both conditions hold. This conclusion depends on the stated assumptions about the inputs.
Guard closed = True; temperature = 60 °C
Question: Does 'below 60' include 60?
Equality belongs to the denied branch. Test 59.9, 60.0 and 60.1 rather than only easy values.
Guard open; temperature = 25 °C; compare and with or
Question: Which expression incorrectly permits enable?
One counterexample disproves the faulty implementation. Keep it as a regression check.
Interactive walkthroughs of Conditionals & Decision Making. Enable JavaScript to step through code, variables, collections and output. The companion notebook remains available below.
Use the notebook to try the ideas yourself. The steps below connect this week's example to the programming practice.
Something to take away: A four-row decision table, three threshold checks, and one counterexample that catches the wrong logical operator.
Read the notebook's teaching cells before these exercises.
Use the notebook's core and optional labels to choose your workload. This activity fits within guided class time.
Notes stay in this browser. Download a copy to keep them.
Give AI the written rule and ask for code. Review the operators without running it first. Then present the guard-open/cool-temperature counterexample and check the revised version against every row.
You can also review the supplied example with a partner. Use the same inputs to compare the reasoning. Follow the syllabus rules for assessed work.