Learning Objectives – after this page you will be able to:
  • Explain what a program, an algorithm and a programming language are.
  • Represent a solution using a flowchart and pseudocode.
  • Distinguish a compiler from an interpreter and know how Python runs code.
  • Identify syntax, runtime and logical errors.
What is Programming?
  • A program is a set of step-by-step instructions that tells a computer what to do.
  • Programming is the process of designing those instructions and writing them in a programming language that a computer can execute.
  • Every program follows the basic Input → Process → Output model: it takes data in, works on it, and produces a result.
  • Programming languages range from low-level (machine code, assembly – close to the hardware) to high-level (Python, Java, C++ – close to human language). High-level languages are easier to read, write and maintain.
Algorithm
An algorithm is a finite, ordered sequence of well-defined steps that solves a problem.

A good algorithm has these properties:

  • Input – zero or more values are supplied.
  • Output – at least one result is produced.
  • Definiteness – every step is clear and unambiguous.
  • Finiteness – it always stops after a finite number of steps.
  • Effectiveness – every step is simple enough to be carried out.
Example – algorithm to find the larger of two numbers
  1. Start.
  2. Read two numbers A and B.
  3. If A > B, display A; otherwise display B.
  4. Stop.
Flowchart

A flowchart is a diagram that shows the steps of an algorithm using standard symbols connected by arrows.

SymbolNameUsed for
Oval (rounded rectangle)TerminalStart and Stop
ParallelogramInput / OutputReading data or displaying results
RectangleProcessCalculations and assignments
DiamondDecisionA Yes/No (True/False) condition
ArrowFlow lineDirection of flow
Small circleConnectorJoining parts of a long flowchart
Start(Oval)
Read A, B(Parallelogram)
Is A > B ?(Diamond)
Print A / Print B(Parallelogram)
Stop(Oval)
Pseudocode

Pseudocode describes an algorithm in plain, structured English that looks like code but follows no strict syntax. It helps you plan logic before writing real code.

BEGIN
    READ A, B
    IF A > B THEN
        PRINT A
    ELSE
        PRINT B
    END IF
END

The same logic in Python:

a = 25
b = 17
if a > b:
    print(a)
else:
    print(b)
Output
25
Compiler vs Interpreter
BasisCompilerInterpreter
WorkingTranslates the whole program into machine code before running it.Translates and executes the program statement by statement.
Output fileProduces a separate executable file.Usually no separate executable.
Error reportingReports errors after analysing the whole program.Stops at the first error it reaches while running.
SpeedCompiled program usually runs faster.Usually slower to run, but quicker to test changes.
ExamplesC, C++Python, JavaScript (commonly)
How Python actually runs: the standard Python implementation (CPython) first compiles your source code into bytecode, and then the Python Virtual Machine interprets that bytecode. Because you run the source directly without a separate build step, Python is usually called an interpreted language.
Types of Errors
ErrorMeaningPython example
Syntax errorThe code breaks the grammar rules of the language; the program does not start.print("Hi" (missing bracket)
Runtime error (exception)The code is valid but fails while running.10 / 0 → ZeroDivisionError
Logical errorThe program runs but gives a wrong result because the logic is wrong.Using + instead of * to find an area
A runtime error caught with try-except
try:
    result = 10 / 0
except ZeroDivisionError as e:
    print("Runtime error:", e)
Output
Runtime error: division by zero
Key Takeaways
  • Plan before coding: algorithm → flowchart or pseudocode → program.
  • Python compiles source to bytecode and interprets it; it is generally called an interpreted language.
  • Syntax errors stop a program from starting, runtime errors stop it while running, and logical errors give wrong answers.
Video : Prerequisite : Programming Basics
Question / Answer (15 questions)

Answer : A program is a set of step-by-step instructions, written in a programming language, that tells a computer how to perform a task. It typically takes input, processes it and produces output.

Answer : An algorithm is a finite, ordered sequence of well-defined steps that solves a problem. Its properties are input, output, definiteness (each step is clear), finiteness (it always ends) and effectiveness (each step can actually be carried out).

Answer : An algorithm is the logical, language-independent solution to a problem, usually written in plain steps. A program is the implementation of an algorithm in a specific programming language so that a computer can execute it.

Answer : A flowchart is a diagram that represents an algorithm using standard symbols connected by arrows. It makes the flow of logic easy to see, which helps in planning, explaining and debugging a solution before coding.

Answer : Start/Stop: oval (terminal). Input/Output: parallelogram. Process: rectangle. Decision: diamond.

Answer : Pseudocode is an informal, structured description of an algorithm written in plain English with programming-like keywords such as IF, ELSE and WHILE. It has no strict syntax and is used to plan logic before writing real code.

Answer : Low-level languages (machine code, assembly) are close to the hardware and hard for humans to read. High-level languages (Python, Java, C++) use English-like syntax, are easier to write and maintain, and are translated into machine instructions by a compiler or interpreter.

Answer : A compiler translates the entire program into machine code before execution and usually creates an executable file. An interpreter translates and executes the program statement by statement, stopping at the first error it reaches while running.

Answer : The standard implementation, CPython, compiles source code into bytecode and then interprets the bytecode in the Python Virtual Machine. Because programs run directly from source without a separate build step, Python is generally called an interpreted language.

Answer : A syntax error occurs when code breaks the grammar rules of the language, so the program cannot start. Example: print("Hello" – the closing bracket is missing.

Answer : A runtime error (exception) occurs while a syntactically valid program is running. Example: 10 / 0 raises ZeroDivisionError.

Answer : A logical error is a mistake in the program’s logic that produces a wrong result without any error message, for example using + instead of * to calculate an area. It is hard to detect because the program runs normally; it is found only by testing outputs.

Answer : Every program receives data (input), performs operations on it (process) and presents results (output). For example, a billing program reads item prices, calculates the total with tax and prints the bill.

Answer : Planning separates problem solving from language details, helps find logical mistakes early, makes the solution easier to explain to others and reduces debugging time later.

Answer : 1. Start. 2. Read number N. 3. If N modulo 2 equals 0, display "Even"; otherwise display "Odd". 4. Stop.
MCQ Test : Check Your Understanding (5 questions)

Select an option and press Check Answer, or answer all questions and press Submit Test to see your score. Each answer comes with an explanation.

Q1. Which flowchart symbol represents a decision?

Show Answer

Correct Answer : C. Diamond
A diamond holds a condition with Yes/No (True/False) branches.

Q2. Which property says an algorithm must always end after a finite number of steps?

Show Answer

Correct Answer : A. Finiteness
Finiteness guarantees the algorithm terminates.

Q3. In CPython, source code is first converted into:

Show Answer

Correct Answer : B. Bytecode
CPython compiles source to bytecode, which the Python Virtual Machine then interprets.

Q4. A program runs without any error message but prints the wrong answer. This is a:

Show Answer

Correct Answer : D. Logical error
Logical errors produce incorrect results without stopping the program.

Q5. Which statement about a compiler is TRUE?

Show Answer

Correct Answer : C. It translates the whole program before execution
A compiler translates the entire source program into machine code before it runs.

Bibliography/References

The notes, questions and MCQs on this page are original explanations written for this course. The works listed below were consulted and are cited for attribution and further reading. Product names, logos and trademarks belong to their respective owners. Short quotations, where used, are marked and attributed.

  1. Python Software Foundation. (n.d.). General Python FAQ. Python 3 Documentation. https://docs.python.org/3/faq/general.html
  2. Python Software Foundation. (n.d.). Glossary. Python 3 Documentation. https://docs.python.org/3/glossary.html
  3. Python Software Foundation. (n.d.). Errors and Exceptions. In The Python Tutorial. https://docs.python.org/3/tutorial/errors.html
  4. International Organization for Standardization. (1985). ISO 5807: Information processing – Documentation symbols and conventions for data, program and system flowcharts. https://www.iso.org/standard/11955.html
  5. Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2022). Introduction to Algorithms (4th ed.). MIT Press.
  6. Aho, A. V., Lam, M. S., Sethi, R., & Ullman, J. D. (2006). Compilers: Principles, Techniques, and Tools (2nd ed.). Pearson.
  7. Downey, A. B. (2024). Think Python (3rd ed.). O’Reilly Media. (Free online edition by Green Tea Press.) https://allendowney.github.io/ThinkPython/