CSC 101: Principles in Information Technology and Computation
Lab training: Interleaved input/output
The instructor's example is showing both the output of the program and the user's input to that program, ensuring that the user types 5 and presses enter. This example is developed in an environment where a user is interacting with a program. However, the program itself doesn't output the newline after "Enter x:" and possibly after the 5, if the instructor's test case expects that.
The program below incorrectly echoes the user's input to the output.
1. Try submitting it for grading. Click "Submit mode," then "Submit for grading." Notice that the test cases fail. The highlighting indicates that output 3 and newline were not expected. In the second test case, the -5 and newline are also not expected.
2. Remove the code that echoes the user's input back to the output, and submit again. Now the test cases should pass.
LAB ACTIVITY 6.16.1: zyLab training: Interleaved input/output
main.py
1 print('Enter x: ')
2 x = int(input())
3
4 print(x) # Student mistakenly is echoing the input to output to match example
5 print('x doubled is:', (2 * x))
Develop mode
Submit mode
Run your program as often as you'd like, before submitting for grading. Enter input values in the first box, then click "Run program" and observe the program's output.