Menu

Inputs, Processes and Outputs

Inputs, Processes and Outputs in Python

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.

LineRoleReason
1Input (with storage)input() receives the battery percentage typed by the user; = stores it.
2Processint() changes the text to a whole number and = stores it.
3ProcessAdds 20 to the percentage and stores the result.
4 and 6ProcessThe if compares values and chooses a branch; else is part of that decision.
5 and 7Outputprint() displays a message.

Practise this

OCR GCSE Computer Science · Inputs, Processes and Outputs