← QCE Digital Solutions Unit 4

Receive, process and display external data

A prototype pipeline: get external data into a variable, process it with a function, then show the result. Each step has its own function, called from main().

Understanding Receive, process and display external data in QCE Digital Solutions Unit 4

What it does: main() calls one function per step and passes the output of each step into the next. A process function receives data, works on it and returns the result so the display step can use it. Data must first be received from the external source, then processed, and only then displayed to the user. Processing changes or calculates with the data, such as finding an average. Reading a file is the receive step. Separate functions make testing and fixing easier. They do not make the program run faster. Calling receive_data() and saving the result in data is how the pipeline brings external data in.

Common mistakes: A function definition must end with a colon. The first line should be def receive():. An average is the total divided by the count. The process step should return total / len(nums), not multiply.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 334–401) and word search (Modules 127–401).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A prototype pipeline has three steps. Which order is correct?
display -> receive -> processreceive -> process -> display
Matches
def main(): result = process_data(data) data = receive_data() show_result(result)
↓
The steps are out of order. process_data(data) is called before data exists, which causes a NameError. The receive step must come first.
Applying
Meanings
Term
receive -> process -> display
Meaning
A prototype pipeline: get external data into a variable, process it with a function, then show the result. Each step has its own function, called from main().
Practice
def receive():
Testing
Gaps
data = ()
Check Answer
Spots
1def receive()
2 raw = '72,85,90'

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Abyssal Dragon' badge — Deep Sea Legend, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A prototype pipeline has three steps. Which order is correct?
A. receive -> process -> display ✓
B. display -> receive -> process
Data must first be received from the external source, then processed, and only then displayed to the user.
2. Which function belongs to the RECEIVE step?
A. def show_result(total): print(total)
B. def get_data(url): return requests.get(url).json() ✓
The receive step brings external data into the program, for example from an API. Printing results is the display step.
3. Which function belongs to the PROCESS step?
A. def average(scores): return sum(scores) / len(scores) ✓
B. def load_file(): return open('data.csv').read()
Processing changes or calculates with the data, such as finding an average. Reading a file is the receive step.
4. Which function belongs to the DISPLAY step?
A. def clean(rows): return [r.strip() for r in rows]
B. def show(avg): print('Average:', avg) ✓
The display step shows the result to the user. Cleaning rows is part of the process step.
5. Which main() follows the one-function-per-step design?
A. data = receive() result = process(data) display(result) ✓
B. print(open('data.csv').read().upper())
main() should call a separate function for each step. Cramming everything into one line makes the code hard to test and maintain.

Match the Pairs

data = receive_data() → The receive step: a function gets external data (such as from a file or API) and stores it in a variable for later steps.
show_result(summary) → The display step: a function shows the processed result to the user, such as a printed summary.
Each pipeline step gets its own function, and main() calls them in order: receive, process, then display. → def main(): data = receive_data() result = process_data(data) show_result(result)
The process step takes the received data as a parameter and returns a new value instead of printing it. → def process_data(data): return sum(data) / len(data)
def main(): result = process_data(data) data = receive_data() show_result(result) → The steps are out of order. process_data(data) is called before data exists, which causes a NameError. The receive step must come first.
def process_data(data): total = sum(data) print(total) → The process function prints the result instead of returning it. Displaying is the job of the display step, and nothing is passed on to show_result.

Key Term

receive -> process -> display
A prototype pipeline: get external data into a variable, process it with a function, then show the result. Each step has its own function, called from main().

Fill in the Blanks

1. def main(): data = receive_data() result = process_data(data)
Hint: Type the name of the function for the first pipeline step, which gets the external data.
2. def main(): raw = receive_data() result = process_data(raw)
Hint: Type the variable name that stores what the receive step returns, so it can be passed to the process step.
3. def display_result(result): print("Average:", result)
Hint: Type the name of the function that performs the final pipeline step, which shows the processed result to the user.
4. def average(values): total = sum(values) return total / len(values)
Hint: Type the keyword that hands the processed value back to main() so the display step can use it.
5. response = requests.get(URL) raw = response.json() result = process_data(raw)
Hint: Type the method name that turns the API response body into Python data ready for the process step.

Spot the Error

Question 1
A def receive()
B raw = '72,85,90'
C return raw
D data = receive()
Line A — A function definition must end with a colon. The first line should be def receive():
Question 2
A def process(nums):
B total = sum(nums)
C return total * len(nums)
Line C — An average is the total divided by the count. The process step should return total / len(nums), not multiply.
Question 3
A def display(avg):
B print('Results')
C print('-------')
D print('Average:' avg)
Line D — print() arguments must be separated by a comma. It should be print('Average:', avg).
Question 4
A def main():
B raw = receive()
C avg = process(raw)
D display(raw)
E main()
Line D — The display step should show the processed result. It must be display(avg), otherwise the process step is skipped.
Question 5
A import requests
B def receive(url):
C r = requests.post(url)
D return r.json()
Line C — The receive step reads data from an API, so it needs requests.get(url). post() is for sending data.

Student with a class code? Join your class →