Talking with Your Program · practice
Input, Process, Output
Many useful programs follow a simple three-part structure:
Input: collect starting values.
Process: calculate or transform those values.
Output: present the result.
Programmers often shorten this to IPO: input, process, output.
See the three parts in code
# Input
minutes_text = input("Minutes: ")
minutes = int(minutes_text)
# Process
seconds = minutes * 60
# Output
print(f"{minutes} minutes is {seconds} seconds.")
The comments label the sections for a human reader. Python ignores everything after # on those lines.
Separating the stages makes a program easier to understand and test. If the final answer is wrong, you can inspect the collected values, then the calculation, then the message.
Input can include conversion
In the IPO pattern, conversion usually belongs near input:
width_text = input("Width: ")
width = int(width_text)
After that point, the rest of the program can treat width as a number. It does not need to remember that the
Process without printing yet
The process stage calculates useful values and gives them names:
area = length * width
Keeping the calculation outside print() makes the result available for later instructions and gives it a meaningful name.
Which instruction belongs in the process stage of a rectangle-area program?
Complete an area program
The starter code already collects and converts a rectangle’s length and width.
Replace the placeholder 0 with a calculation that multiplies length by width.
If the person enters 6 and then 4, the final line should be:
Area: 24
Keep the Input, Process, and Output comments. They make the structure visible and prepare you for the chapter project.
Task
Replace the placeholder 0 with an length * width.
If the two inputs are 6 and 4, the final line should be:
Area: 24