0% found this document useful (0 votes)
8 views3 pages

Program Development Cycle Explained

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Program Development Cycle Explained

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Module 2: Program Development Cycle

1. Program Development Cycle


5 phases to create a working program:
1. Design the program – Plan before coding.
2. Write the code – Write in a high-level language (like Python).
3. Correct syntax errors – Fix code structure mistakes.
4. Test the program – Check for logic errors (incorrect results).
5. Correct logic errors – Debug and fix flawed logic.

2. Design Process
Understand the task: Know what the program should do (often by talking to the customer).
Break down the task: Create an algorithm – a step-by-step logical procedure.

3. Algorithm Tools
Pseudocode: Informal 'fake code' without syntax rules. Focuses on logic.
Example:
Input hours worked
Input hourly pay rate
Calculate gross pay = hours * rate
Display gross pay
Flowchart: Visual diagram of steps.
Symbols:
Oval: Start/End
Parallelogram: Input/Output
Rectangle: Processing (e.g., calculations)

4. Input, Processing, Output (IPO)


Programs typically:
- Receive input (e.g., user data).
- Process it (e.g., perform calculations).
- Produce output (e.g., display results).

5. Displaying Output: print() Function


Used to display output.
Example: print('Hello world')
Can print multiple items: print('Name:', name)

6. Strings
Sequence of characters used as data.
String literal: String written in code (enclosed in quotes).
Use single (') or double (") quotes.
Use triple quotes (""" or ''') for multi-line strings or strings containing both single and double quotes.

7. Comments
Notes for programmers (ignored by Python).
Start with #.
Use to explain code purpose.

8. Variables
Names that represent values stored in memory.
Created with assignment statements: variable = value
Example: age = 25
Variable names:
- Cannot use Python keywords.
- Cannot contain spaces.
- Must start with a letter or _.
- Case-sensitive.
- Use descriptive names (e.g., gross_pay instead of x).

9. Data Types
int: Integer (whole number).
float: Floating-point (decimal number).
str: String.
Use type() to check data type.

10. Reading Input: input() Function


Reads user input as a string.
Format: variable = input(prompt)
Example: name = input('Enter your name: ')
Convert to numbers:
int(): Convert to integer.
float(): Convert to float.
Example: age = int(input('Enter age: '))

11. Performing Calculations


Math operators:
+ (addition), - (subtraction), * (multiplication)
/ (float division), // (integer division), % (remainder/modulus)
** (exponent)
Operator precedence (order of operations):
1. Parentheses ()
2. Exponentiation **
3. Multiplication *, Division /, //, %
4. Addition +, Subtraction -
Mixed-type expressions: int and float → result is float.

12. Formatting Output


format(value, format_specifier):
Examples:
format(123.456, '.2f') → '123.46' (2 decimal places)
format(12345, ',d') → '12,345' (with commas)
format(0.5, '.0%') → '50%' (percentage)
Escape characters (start with \):
\n: New line
\t: Tab
\', \": Quotes
\\: Backslash

13. Named Constants


Names for values that do not change.
Use uppercase letters (e.g., INTEREST_RATE = 0.069).
Benefits:
- Code is more readable.
- Easier to update values.
- Reduces errors (avoid 'magic numbers').

Key Terms
Algorithm: Step-by-step procedure.
Pseudocode: Informal code-like description.
Flowchart: Visual representation of an algorithm.
Syntax error: Code structure mistake.
Logic error: Mistake in program logic (incorrect result).
Variable: Name for a stored value.
String: Sequence of characters.
Comment: Explanatory note in code.
Operator precedence: Order in which operations are performed.
Named constant: Unchanging value with a descriptive name.

You might also like