Module 1: Programming Fundamentals, Algorithms & Flowcharts

Learn what programming is, how programming languages evolved, how to solve problems, design algorithms, write pseudocode, draw flowcharts, and convert logic into code.

ProgrammingAlgorithmsPseudocodeFlowchartsProblem Solving
Think
Logically
Design
Algorithms
Draw
Flowcharts
Convert
to Code

1.1 Module Overview

This module introduces the foundation of programming. Before learners write full Python programs, they must understand how to think like a programmer. Programming is not only typing commands; it is a structured way of analyzing problems, designing logical steps, and converting those steps into working code.

The module covers the meaning of programming, the evolution of programming languages, types of programming languages, compiled and interpreted languages, problem-solving techniques, algorithm design, pseudocode, flowchart symbols, decision and iteration flowcharts, and converting flowcharts into Python code.

Learning Outcome: By the end of this module, learners should be able to explain programming concepts, design algorithms, write pseudocode, draw basic flowcharts, and convert simple flowcharts into Python programs.
1Understand Problem
2Design Algorithm
3Write Pseudocode
4Draw Flowchart
5Write Code

1.2 Learning Objectives

  • Define programming and explain its importance in modern digital industries.
  • Describe the history and evolution of programming languages.
  • Identify different types of programming languages and their uses.
  • Differentiate between compiled and interpreted languages.
  • Apply problem-solving techniques before writing code.
  • Design algorithms using step-by-step logical instructions.
  • Write clear pseudocode for simple problems.
  • Use common flowchart symbols correctly.
  • Create decision and iteration flowcharts.
  • Convert flowcharts into simple Python programs.

1.3 What is Programming?

Programming is the process of writing instructions that tell a computer what to do. These instructions are written using a programming language such as Python, Java, C++, JavaScript, or C#.

A computer cannot guess what a user wants. It follows instructions exactly. Therefore, a programmer must write instructions clearly, logically, and in the correct sequence.

Human ActivityProgramming ConceptExample
Calculate salaryArithmetic operationssalary = basic + allowance
Check pass or failDecision makingif marks >= 50
Repeat attendance checkingLoopingfor student in class_list
Store student recordsData structuresstudent = {"name":"Amin"}
Read report from fileFile handlingopen("report.txt")
Simple Definition: Programming is giving step-by-step instructions to a computer to solve a problem or complete a task.

1.4 Why Programming is Important

Automation

Programming reduces repetitive manual work and increases productivity.

Problem Solving

It trains learners to think logically and break complex problems into smaller steps.

Digital Careers

Programming supports careers in AI, cyber security, data science, automation, software, and web development.

Innovation

It enables learners to create tools, apps, websites, systems, and business solutions.

1.5 History and Evolution of Programming Languages

Programming languages have evolved from machine-level instructions to modern high-level languages that are easier for humans to understand.

GenerationLanguage TypeDescriptionExample
1st GenerationMachine LanguageUses binary numbers 0 and 1. Very difficult for humans.10110000
2nd GenerationAssembly LanguageUses short symbolic instructions close to hardware.MOV, ADD, SUB
3rd GenerationHigh-Level LanguagesHuman-readable languages for general programming.C, C++, Java, Python
4th GenerationProblem-Oriented LanguagesDesigned for specific business or data tasks.SQL, MATLAB
5th GenerationAI and Logic-Based LanguagesUsed for artificial intelligence and logic programming.Prolog, AI platforms

Evolution Timeline

1Machine Code
2Assembly
3C / C++
4Java / C#
5Python / AI Tools
Key Idea: Programming languages evolved to make software development easier, faster, more reliable, and more accessible to humans.

1.6 Types of Programming Languages

TypeDescriptionExamplesCommon Use
Low-Level LanguagesClose to machine hardware.Machine Language, AssemblyHardware control, embedded systems
High-Level LanguagesHuman-readable and easier to write.Python, Java, C++Applications, AI, systems
Scripting LanguagesUsed for automation and quick tasks.Python, JavaScript, BashAutomation, web, cyber security
Markup LanguagesUsed to structure content, not full programming logic.HTML, XMLWeb pages, documents
Query LanguagesUsed to manage and retrieve data.SQLDatabases, analytics
Object-Oriented LanguagesOrganize code using classes and objects.Java, Python, C#Large applications
Important: HTML is not normally considered a full programming language because it structures content but does not perform decision-making or calculations by itself.

1.7 Compiled vs Interpreted Languages

Programming languages can be executed in different ways. Some are compiled before execution, while others are interpreted line by line.

Compiled LanguageInterpreted Language
The whole program is converted into machine code before running.The program is executed line by line by an interpreter.
Usually faster after compilation.Usually easier for learning, testing, and debugging.
Compilation errors must be fixed before execution.Errors may appear while the program is running.
Examples: C, C++, Go, RustExamples: Python, JavaScript, PHP

Python as an Interpreted Language

Python is commonly used as an interpreted language. Learners can write a line of code and run it quickly, which makes Python suitable for beginners.

print("Python runs this line using an interpreter")
Expected Output:
Python runs this line using an interpreter

1.8 Problem Solving Techniques

Good programming begins before coding. A programmer must first understand the problem clearly, identify inputs, decide the processing steps, and define the expected output.

IPO Model

StageQuestionExample
InputWhat data is needed?Marks, price, quantity, age
ProcessWhat calculation or decision is required?Total = price × quantity
OutputWhat result should be displayed?Total price, pass/fail result

Problem-Solving Steps

  1. Understand the problem statement.
  2. Identify the required input.
  3. Identify the expected output.
  4. Break the problem into smaller tasks.
  5. Design an algorithm.
  6. Write pseudocode or draw a flowchart.
  7. Convert the logic into code.
  8. Test with sample data.
Example: To calculate total training fee, the input is number of participants and fee per participant. The process is multiplication. The output is total fee.

1.9 Algorithm Design

An algorithm is a step-by-step procedure to solve a problem. It must be clear, finite, logical, and produce a result.

Characteristics of a Good Algorithm

  • Clear: Each step should be easy to understand.
  • Finite: It must end after a number of steps.
  • Input: It may accept data for processing.
  • Output: It must produce a result.
  • Effective: Each step must be practical and executable.

Example Algorithm: Calculate Total Price

  1. Start
  2. Input quantity
  3. Input price per item
  4. Calculate total = quantity × price per item
  5. Display total
  6. End

Example Algorithm: Check Pass or Fail

  1. Start
  2. Input marks
  3. If marks are greater than or equal to 50, display “Pass”
  4. Otherwise, display “Fail”
  5. End

1.10 Writing Pseudocode

Pseudocode is a simple English-like way of writing program logic. It is not written in exact programming syntax, but it helps programmers plan before coding.

Why Use Pseudocode?

  • It helps learners focus on logic instead of syntax.
  • It is easier to understand than actual code.
  • It can be converted into any programming language.
  • It helps detect missing steps before coding.

Pseudocode Example: Total Price

START
INPUT quantity
INPUT price
total = quantity * price
DISPLAY total
END

Pseudocode Example: Pass or Fail

START
INPUT marks
IF marks >= 50 THEN
    DISPLAY "Pass"
ELSE
    DISPLAY "Fail"
END IF
END

Pseudocode Example: Repeat 5 Times

START
FOR counter FROM 1 TO 5
    DISPLAY "Welcome to PDTC"
END FOR
END

1.11 Flowchart Symbols

A flowchart is a visual diagram that represents the steps of an algorithm. It uses standard symbols to show start/end, input/output, processing, decisions, and flow direction.

Start / End

Terminator

Shows where the process starts or ends.

Input / Output

Input / Output

Shows data entry or result display.

Process

Process

Shows calculation or action.

Decision

Decision

Shows yes/no or true/false decision.

Flow Direction

Arrows are used to show the direction of movement from one step to another in a flowchart.

1.12 Decision Flowcharts

A decision flowchart is used when the program must choose between two or more paths. It commonly uses IF, IF-ELSE, or IF-ELIF-ELSE logic.

Example: Pass or Fail Decision

   ┌─────────┐
   │  Start  │
   └────┬────┘
        ↓
 ┌──────────────┐
 │ Input Marks  │
 └────┬─────────┘
      ↓
   ◇ Marks >= 50? ◇
    /             \
  Yes              No
  ↓                ↓
┌──────┐        ┌──────┐
│Pass  │        │Fail  │
└──┬───┘        └──┬───┘
   ↓               ↓
   └──────→ End ←──┘

Equivalent Python Code

marks = 65

if marks >= 50:
    print("Pass")
else:
    print("Fail")

1.13 Iteration Flowcharts

Iteration means repetition. An iteration flowchart is used when the program needs to repeat a task multiple times using loops.

Example: Display Numbers 1 to 5

   ┌─────────┐
   │  Start  │
   └────┬────┘
        ↓
 ┌──────────────┐
 │ counter = 1  │
 └────┬─────────┘
      ↓
 ◇ counter <= 5? ◇
   /           \
 Yes            No
 ↓              ↓
┌──────────────┐ ┌─────┐
│Display count │ │ End │
└────┬─────────┘ └─────┘
     ↓
┌──────────────┐
│counter += 1  │
└────┬─────────┘
     └──── back to decision

Equivalent Python Code

counter = 1

while counter <= 5:
    print(counter)
    counter = counter + 1
Expected Output:
1
2
3
4
5

1.14 Converting Flowcharts to Code

To convert a flowchart into code, read each symbol in sequence and translate it into a programming statement.

Flowchart SymbolProgramming Code EquivalentPython Example
Start / EndProgram begins or ends# Start of program
InputUse input statementname = input("Enter name: ")
ProcessUse calculation or assignmenttotal = price * quantity
DecisionUse if / elseif marks >= 50:
IterationUse for or while loopwhile counter <= 5:
OutputUse print statementprint(total)

Full Example: Calculate Training Fee

Problem: Calculate total fee for a course based on number of participants and fee per participant.

Pseudocode

START
INPUT participants
INPUT fee_per_participant
total_fee = participants * fee_per_participant
DISPLAY total_fee
END

Python Code

participants = int(input("Enter number of participants: "))
fee_per_participant = float(input("Enter fee per participant: "))

total_fee = participants * fee_per_participant

print("Total Fee: RM", total_fee)

Sample Output

Enter number of participants: 10
Enter fee per participant: 250
Total Fee: RM 2500.0

1.15 Practical Activities

Activity 1: Daily Life Algorithm

Write an algorithm for one daily activity such as making tea, registering for a course, or withdrawing money from an ATM.

Activity 2: Pseudocode Practice

Write pseudocode to calculate the average marks of three subjects.

Activity 3: Decision Flowchart

Draw a flowchart to check whether a number is positive or negative.

Activity 4: Iteration Flowchart

Draw a flowchart to display numbers from 1 to 10.

Mini Project

Create an algorithm, pseudocode, flowchart, and Python code for a simple student grading system.

1.16 Interactive Final Assessment Quiz

Each correct answer gives +1 mark. Each wrong answer gives -0.5 mark.

1. Programming means writing instructions for a computer.

2. Which language generation uses binary instructions?

3. Python is commonly considered an interpreted language.

4. A flowchart decision symbol is usually represented by:

5. Pseudocode must follow exact Python syntax.

6. IPO stands for Input, Process, Output.

7. Iteration means repetition.

8. Which Python statement is used to display output?

9. An algorithm should be clear, finite, and logical.

10. The rectangle symbol in a flowchart normally represents a process.

Your Score: 0

1.17 Module Summary

This module introduced programming, programming language evolution, types of languages, compiled versus interpreted execution, problem-solving techniques, algorithm design, pseudocode, flowchart symbols, decision and iteration flowcharts, and converting flowcharts into Python code.

Remember: Strong programmers first design logic clearly before writing code. Algorithms, pseudocode, and flowcharts help convert ideas into working programs.