Computer Science GCES EDEXCEL
-
Decomposition And Abstraction Edexcel2 主题
-
Algorithms Edexcel11 主题
-
Follow And Write Algorithms Edexcel
-
Introduction To Programming Concepts Edexcel
-
Basic Programming Concepts Edexcel
-
Variables Constants And Assignments Edexcel
-
Data Structures And Arrays Edexcel
-
Arithmetic Relational And Logical Operations Edexcel
-
Determine Outputs Of An Algorithm Edexcel
-
Types Of Errors Edexcel
-
Standard Sorting Algorithms Edexcel
-
Standard Searching Algorithms Edexcel
-
Algorithm Efficiency Edexcel
-
Follow And Write Algorithms Edexcel
-
Truth Tables Edexcel3 主题
-
Binary Edexcel6 主题
-
Data Representation Edexcel4 主题
-
Data Storage And Compression Edexcel2 主题
-
Hardware Edexcel5 主题
-
Software Edexcel3 主题
-
Programming Languages Edexcel2 主题
-
Networks Edexcel7 主题
-
Network Security Edexcel2 主题
-
Environmental Issues Edexcel1 主题
-
Ethical And Legal Issues Edexcel3 主题
-
Cybersecurity Edexcel2 主题
-
Develop Code Edexcel6 主题
-
Constructs Edexcel4 主题
-
Data Types And Data Structures Edexcel5 主题
-
Operators Edexcel1 主题
-
Subprograms Edexcel2 主题
Using Decomposition And Abstraction Edexcel
Exam code:1CP2
Using Decomposition & Abstraction to Analyse,
Understand & Solve Problems
Examiner Tips and Tricks
Before attempting to use decomposition and abstraction it is important to understand the process by reading here
Task
-
Write a program that calculates the total cost of a pizza order. The program should include the following features:
-
Size: The user can choose from three sizes (small, medium, and large) with different base prices
-
Toppings: The user can choose any number of toppings from a list, with each topping having a set price
-
Discount: There is a 10% discount applied to orders over £20
-
Abstraction
-
Create a function that calculates and returns the base price of the pizza by taking the size as an input
Decomposition
-
Break down the task in to smaller, more manageable pieces
-
For example, using separate functions to:
-
Get the user input for pizza size and toppings
-
Calculate cost of toppings
-
Apply discount (if applicable)
-
Output final order total
-
Python code
|
# ———————————————————————– # ———————————————————————–
# ———————————————————————– # This function displays options and gets valid user input from the provided list # ———————————————————————–
# ———————————————————————– # This function calculates the total cost of selected toppings # ———————————————————————–
# ———————————————————————– # This function applies a 10% discount if the total cost exceeds £20 # ———————————————————————–
# ———————————————————————– # This function coordinates the program flow and calls other functions # ———————————————————————–
# ———————————————————————– # Main program starts here # ———————————————————————–
|
Responses