logo

Question detail

Using Python, write a small composition abstraction that combines three procedures: one to obtain data, one to process the data and one to display the result. Explain how the three procedures form a compound procedure.

Try the question, check the answer, then read the explanation to understand the curriculum point.

At a glance

Question

Type

practice

Style

Topic

Abstraction and automation

Exam-style question

Try this first

Using Python, write a small composition abstraction that combines three procedures: one to obtain data, one to process the data and one to display the result. Explain how the three procedures form a compound procedure.

Model answer

What a good answer should say

  • def get_data(): return 8 def process_data(value): return value * 2 def display_data(value): print(value) def run_task(): data = get_data() result = process_data(data) display_data(result) run_task() The procedure run_task is a compound procedure because it combines calls to get_data, process_data and display_data.
  • The smaller procedures are combined to create one larger operation.

Explanation

Why this works

The answer demonstrates composition by combining several procedures into run_task. Each smaller procedure performs part of the operation, while run_task forms the larger compound procedure.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions

No questions are published for this page yet.