Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if both inputs are ON using AND logic.
PLC Programming
if input1 [1] input2 then output = ON end if
Attempts:
3 left
💡 Hint
Common Mistakes
Using OR instead of AND will turn output ON if either input is ON.
Using NOT or XOR will not check both inputs correctly.
✗ Incorrect
The AND operator ensures both input1 and input2 must be ON for the output to be ON.
2fill in blank
mediumComplete the code to turn ON the motor only if sensor1 and sensor2 are both active.
PLC Programming
if sensor1 [1] sensor2 then motor = ON else motor = OFF end if
Attempts:
3 left
💡 Hint
Common Mistakes
Using OR will run the motor if any sensor is active, not both.
XOR and NOR do not represent simple AND logic.
✗ Incorrect
Using AND ensures the motor runs only when both sensors are active.
3fill in blank
hardFix the error in the code to correctly implement series logic with two switches.
PLC Programming
if switch1 [1] switch2 then light = ON end if
Attempts:
3 left
💡 Hint
Common Mistakes
Using OR will turn the light ON if either switch is ON.
NOT and XOR do not represent series logic.
✗ Incorrect
AND is needed to ensure the light turns ON only when both switches are ON.
4fill in blank
hardFill both blanks to create a condition that turns ON the alarm only if button1 and button2 are pressed.
PLC Programming
if button1 [1] button2 [2] then alarm = ON end if
Attempts:
3 left
💡 Hint
Common Mistakes
Using OR will activate alarm if any button is pressed.
Using != FALSE is less clear than == TRUE here.
✗ Incorrect
Using AND and == TRUE ensures both buttons are pressed to activate the alarm.
5fill in blank
hardFill all three blanks to create a dictionary that maps sensor names to their status only if the status is ON.
PLC Programming
status_map = { [1]: [2] for [1], [2] in sensors.items() if [2] == [3] }Attempts:
3 left
💡 Hint
Common Mistakes
Using 'OFF' in the filter will exclude ON sensors.
Using wrong variable names breaks the comprehension.
✗ Incorrect
The dictionary comprehension uses sensor and status variables and filters for status == 'ON'.
