Student Result Calculator
This is the running example used throughout the chapter. Enter marks (out of 100) for six subjects and watch the total and percentage calculate live — exactly what the algorithm, flowchart, and Python code on this page describe.
Total & Percentage
● livePhases in Programming
Writing a program is like constructing a building — you need a plan before you start. Programming follows a clear, repeatable cycle from problem to finished product, combining analytical thinking (breaking a problem into parts) and creative thinking (finding smart ways to solve them).
Problem Identification1
Define the gap between the current state and the desired result.
Algorithm & Flowchart2
Design the logical plan in plain language and as a diagram.
Coding3
Translate the plan into a programming language (source code).
Translation4
Convert source code into machine-readable object code.
Debugging5
Find and correct syntax, logical, and run-time errors.
Execution & Testing6
Run the program and verify its results under various conditions.
Documentation7
Record how the program works, for users and future developers.
Two Kinds of Thinking
Analytical: break the big problem down. Creative: find smart ways to solve the parts.
Algorithms
An algorithm is a step-by-step procedure to solve a problem — like a recipe, or directions to a friend's house. The term comes from Muhammad Ibn Musa Al-Khwarizmi, a 9th-century Persian mathematician often called the father of algebra.
Guidelines for Writing Algorithms
Storing Information
Give data unique names (like Marks, Age, Total) so it can be stored and found again.
Writing the Steps
Input: Input, Read, Get. Process: Calculate, Add, Set. Output: Print, Display, Show.
General Rules
Every algorithm has a Start and Stop, uses clear unambiguous steps, and must always end.
Benefits of Using Algorithms
Efficient Problem-Solving
Breaks large problems into smaller, easy-to-manage steps.
Improved Accuracy
A correct, step-by-step algorithm reduces the chance of mistakes.
Scalability
Logic that works for one class can scale to an entire school.
Foundation of Programming
Acts as the blueprint before writing code in Python, C++, etc.
Flowcharts
A flowchart is a pictorial representation of an algorithm, using standard geometric shapes connected by arrows to show the direction of flow.
| Symbol | Name | Description |
|---|---|---|
start / end |
Start / End (Terminator) | Marks the beginning or end of a process. |
process |
Process / Action Step | Represents a process, task, or action to be performed. |
Yes/No |
Decision Point | Indicates a decision or branching point (Yes/No or True/False). |
I/O |
Input / Output | Represents input to or output from a process (user input, data display). |
| ↓ ↑ → | Flow line | Shows the direction of flow between steps. |
| ⭕ | Connector / Link | Connects or links different sections of a flowchart. |
Advantages & Limitations
Better Communication
A visual map of the program is easier to explain than lines of code.
Effective Analysis
Helps spot logical errors and dead ends before writing any code.
Time-Consuming
Drawing a neat, correct flowchart takes longer than writing text.
Difficult to Modify
A logic change often means redrawing the whole diagram.
Flow of Control
The path through which a computer takes instructions is the flow of control. Real-world problems need more than a straight list of steps — three primary types handle choice and repetition.
Sequential (The Straight Line)
Every instruction executes in the exact order written, top to bottom — like reading a book, or baking a cake step by step.
Branching / Selection (The Crossroad)
The program checks a condition and follows one of two paths — like a traffic light. Represented with If... Then... Else logic.
Iteration / Looping (The Cycle)
A set of instructions repeats while a condition remains true — like climbing a flight of stairs, one step at a time.
Example — Highest of two scores (Branching)
If M1 > M2, then Go to Step 4 else Goto Step 5.
Coding & Translation
Computers understand only Machine Language (binary 0s and 1s). High-Level Languages like Python bridge human language and machine code — the instructions we write are called Source Code, and a Language Translator converts it into machine-readable Object Code.
Compiler vs Interpreter
| Aspect | Compiler | Interpreter |
|---|---|---|
| Translation | Translates the whole program at once | Translates and executes line by line |
| Object code | Generates a separate object code file | Does not generate an object code file |
| Errors | Scans the entire code and lists all errors at the end | Stops execution immediately when the first error is found |
| Example languages | C, C++ | Python, JavaScript |
Debugging, Execution & Documentation
An error in a program is historically called a Bug. Debugging is a continuous process of identifying, locating, and correcting bugs — the programmer acts like a doctor diagnosing the program.
Syntax Error
Mistakes in the rules (grammar) of the language that prevent the program from running — e.g. typing prnt instead of print. Caught during translation.
Logical Error
Mistakes in the logic that make the program give the wrong result without crashing — e.g. forgetting brackets in a formula. Found during testing.
Run-time Error
Mistakes that happen while the program is running, causing it to stop suddenly — e.g. dividing by zero. Triggered by unexpected input.
Execution and Testing
Execution is simply running a program to process data. Testing is the intentional process of checking that program for errors — normal values, boundary values (0 or 100), and invalid input are all tried before a program is considered complete.
Documentation
Internal Documentation
Comments written directly in the source code to explain logic to other programmers.
External Documentation
User and technical manuals that provide installation and usage guides for non-programmers.
Programming Paradigms
A programming paradigm is a fundamental style of programming that guides how the programmer thinks about and structures code — there is no single "correct" way to write a program.
Procedure Oriented Programming (POP)C, Pascal
Treats a program like a step-by-step recipe, broken into procedures executed from top to bottom. Easy to organise, but data shared across the whole program can be risky for complex projects.
Object Oriented Programming (OOP)Python, Java, C++
Models software after real-world entities as Objects, bundling Data (attributes) and Methods (actions) together. Hides data to prevent errors — effective for complex systems, though it takes more initial setup.
Quick Recap
Tap a question to reveal the answer.
Who is known as the father of algebra and the concept of algorithms?
Muhammad Ibn Musa Al-Khwarizmi, a Persian mathematician who lived around 820 AD.
Which symbol in a flowchart represents a decision or branching point?
The Diamond (Rhombus).
What is an algorithm?
A step-by-step procedure to solve a problem, written in plain language before any code is written — it must have a clear Start and Stop, unambiguous steps, and always terminate.
What is the difference between a Compiler and an Interpreter?
A compiler translates the entire source program at once into a separate object code file and lists all errors at the end. An interpreter translates and executes line by line, generates no separate object code, and stops at the first error.
"Division by Zero" — what type of error is this?
A Run-time Error — the code has no syntax or logical flaw, but crashes when it meets an impossible operation during execution.
What is the difference between execution and testing of a program?
Execution is simply running the program to process data. Testing is the intentional process of checking the program for errors by verifying its results under different conditions — normal, boundary, and invalid input.
Why is Documentation important for the maintenance of software?
It acts as a memory aid for the original programmer, enables teamwork by letting others understand the code without constant explanation, and ensures future developers can maintain or upgrade the system.
Compare procedural and object oriented programming paradigms.
Procedural (POP) breaks a program into a sequence of procedures acting on shared data — simple but risky for large projects. Object Oriented (OOP) bundles data and methods into self-contained objects that model real-world entities, which is safer and more scalable for complex systems.