Inputs, Processes and Outputs
Every Python program can be described by how it handles data. A call to input() takes data from the user, so it is an input. A call to print() displays data, so it is an output. The work that changes the input into the output is a process.
Processes include assignment with =, calculations such as adding or multiplying, and if statements that compare values and choose what happens next. Storing a value in a variable is work done by the program, so it is a process too. When an assignment line includes a call to input(), the call is the input and storing the typed value is also a process. The line as a whole is usually classed as an input, because it brings new data into the program.
battery = input("Battery %: ")
battery = int(battery)
after_charge = battery + 20
if after_charge >= 100:
print("Fully charged")
else:
print("Not full yet")Output when the user types 75:
Battery %: 75
Not full yet
Each line in the program has a role. Line 1 gets data from the user. Lines 2 to 4 convert, calculate and decide. The print() lines show a result.
| Line | Role | Reason |
|---|---|---|
| 1 | Input (with storage) | input() receives the battery percentage typed by the user; = stores it. |
| 2 | Process | int() changes the text to a whole number and = stores it. |
| 3 | Process | Adds 20 to the percentage and stores the result. |
| 4 and 6 | Process | The if compares values and chooses a branch; else is part of that decision. |
| 5 and 7 | Output | print() displays a message. |
OCR GCSE Computer Science · Inputs, Processes and Outputs