Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to scale the input value from 0-10V to 0-100 units.
PLC Programming
scaled_value = (input_voltage [1] 10) * 100
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication instead of division causes incorrect scaling.
Adding or subtracting the voltage does not normalize the value.
✗ Incorrect
We divide the input voltage by 10 to normalize it between 0 and 1 before scaling.
2fill in blank
mediumComplete the code to convert a raw sensor value (0-4095) to a temperature in Celsius (0-100°C).
PLC Programming
temperature_c = (raw_value [1] 4095) * 100
Attempts:
3 left
💡 Hint
Common Mistakes
Multiplying raw_value by 4095 causes wrong results.
Adding or subtracting raw_value does not scale properly.
✗ Incorrect
Dividing the raw value by 4095 normalizes it before scaling to temperature.
3fill in blank
hardFix the error in the scaling formula to convert a 4-20mA signal to 0-100 units.
PLC Programming
scaled_units = ((current_mA [1] 4) / 16) * 100
Attempts:
3 left
💡 Hint
Common Mistakes
Adding 4 instead of subtracting causes wrong offset.
Multiplying or dividing by 4 instead of subtracting causes errors.
✗ Incorrect
Subtract 4mA to zero the signal before scaling by the 16mA span.
4fill in blank
hardFill both blanks to scale a sensor value from 100-500 to 0-200 units.
PLC Programming
scaled_value = ((sensor_value [1] 100) * 200) / [2]
Attempts:
3 left
💡 Hint
Common Mistakes
Adding 100 instead of subtracting causes wrong offset.
Dividing by 100 instead of 400 causes incorrect scaling.
✗ Incorrect
Subtract 100 to zero the input range, then divide by 400 (500-100) to normalize before scaling.
5fill in blank
hardFill all three blanks to create a dictionary mapping sensor names to scaled values above 50.
PLC Programming
scaled_sensors = { [1]: [2] for [3], val in sensors.items() if val > 50 }Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names causes errors.
Not scaling the value properly results in wrong output.
✗ Incorrect
Use 'name' as key, scale value by multiplying by 2, and iterate with 'name' as variable.
