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 主题
Techniques To Maintain Programs Edexcel
Exam code:1CP2
Techniques to Maintain Programs
How do you write programs that are easy to maintain?
-
Easy to maintain programs are written using techniques that make code easy to read
-
Programmers should be consistent with the use of techniques such as:
-
Layout – spacing between sections
-
Indentation – clearly defined sections of code
-
Comments – explaining key parts of the code
-
Meaningful variable names – describe what is being stored
-
White space – adding suitable spaces to make it easy to read
-
-
When consistency is applied, programs are easy to maintain
Example easy to maintain program
|
Python code |
|---|
|
# ———————————————————————– “”” Calculates the area of a triangle given its base and height. Inputs: base (float): The length of the triangle’s base (positive value). height (float): The height of the triangle from the base (positive value). Returns: The calculated area of the triangle (float). Raises: ValueError: If either base or height is non-positive. “”” # ———————————————————————–
# ———————————————————————– # Prompts the user for triangle base and height, calculates and prints the area # ———————————————————————–
# Call the area calculation function
# ———————————————————————— # Main program # ————————————————————————
|
Responses