Challenge - 5 Problems
Operator Input Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediateWhat is the output when the operator inputs '123' on a numeric input screen?
Assume the PLC program reads the operator input from a numeric input screen and stores it in a variable called
InputValue. The program then outputs InputValue * 2. What is the output if the operator inputs '123'?PLC Programming
InputValue = 123 Output = InputValue * 2 print(Output)
Attempts:
2 left
💡 Hint
Think about how numeric input is stored and how multiplication works with numbers.
✗ Incorrect
The operator inputs the number 123, which is stored as a numeric value. Multiplying 123 by 2 results in 246.
🧠 Conceptual
intermediateWhich data type is best for storing operator input from a text input screen?
An operator enters a code like 'AB123' on a text input screen. Which data type should the PLC program use to store this input?
Attempts:
2 left
💡 Hint
Consider the type of data that includes letters and numbers.
✗ Incorrect
Text input that includes letters and numbers should be stored as a string because integers and floats only store numbers, and booleans store true/false values.
🔧 Debug
advancedWhy does this operator input screen code cause an error?
The PLC program code snippet below is intended to read an operator's numeric input and print it. Why does it cause an error?
InputValue = input('Enter number: ')
Result = InputValue + 10
print(Result)Attempts:
2 left
💡 Hint
Think about the type of data returned by input and what happens when you add a number to it.
✗ Incorrect
The input function returns a string. Adding an integer to a string causes a TypeError because they are different types.
🚀 Application
advancedHow many items are stored after this operator input screen saves multiple entries?
An operator inputs three values sequentially on a numeric input screen. The program stores each input in a list called
Entries. After inputs 5, 10, and 15, what is the length of Entries?PLC Programming
Entries = [] Entries.append(5) Entries.append(10) Entries.append(15) print(len(Entries))
Attempts:
2 left
💡 Hint
Count how many times values are added to the list.
✗ Incorrect
Each append adds one item to the list. After three appends, the list length is 3.
📝 Syntax
expertWhat error does this operator input screen code produce?
Consider this PLC program snippet that reads operator input and tries to convert it to an integer:
InputValue = input('Enter number: ')
ConvertedValue = int InputValue
print(ConvertedValue)
What error will this code produce?Attempts:
2 left
💡 Hint
Look carefully at how the int function is called.
✗ Incorrect
The int function requires parentheses around its argument. Missing parentheses cause a SyntaxError.
