Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to convert an integer to a real number.
PLC Programming
REAL_Value := [1](INT_Value);Attempts:
3 left
💡 Hint
Common Mistakes
Using REAL_TO_INT which converts in the opposite direction.
Using TO_STRING which converts to text, not numbers.
✗ Incorrect
Use INT_TO_REAL to convert an integer value to a real (floating point) value.
2fill in blank
mediumComplete the code to convert a real number to an integer.
PLC Programming
INT_Value := [1](REAL_Value);Attempts:
3 left
💡 Hint
Common Mistakes
Using INT_TO_REAL which converts in the wrong direction.
Using STRING_TO_INT which expects a string input.
✗ Incorrect
Use REAL_TO_INT to convert a real number to an integer by truncating the decimal part.
3fill in blank
hardFix the error in the code to convert a boolean to an integer.
PLC Programming
INT_Value := [1](BOOL_Value);Attempts:
3 left
💡 Hint
Common Mistakes
Using INT_TO_BOOL which converts in the opposite direction.
Using STRING_TO_BOOL which is unrelated here.
✗ Incorrect
Use BOOL_TO_INT to convert a boolean value (TRUE/FALSE) to integer (1/0).
4fill in blank
hardFill both blanks to convert a string to a real number and then to an integer.
PLC Programming
REAL_Value := [1](String_Value); INT_Value := [2](REAL_Value);
Attempts:
3 left
💡 Hint
Common Mistakes
Using STRING_TO_INT directly which may fail if string is not integer format.
Using INT_TO_REAL which converts in the wrong direction.
✗ Incorrect
First convert string to real with STRING_TO_REAL, then convert real to int with REAL_TO_INT.
5fill in blank
hardFill all three blanks to create a dictionary mapping string keys to integer values, filtering only keys with length greater than 3.
PLC Programming
Dict_Result := { [1]: [2] for [3] in String_List if LEN([3]) > 3 };Attempts:
3 left
💡 Hint
Common Mistakes
Using 'value' as loop variable which is undefined.
Not converting string to int for dictionary values.
✗ Incorrect
Use 'key' as dictionary key, convert it to int for value, and iterate with 'key' over String_List.
