Monday, October 5, 2026

Java Class 1 notes computer science university programming basics, JDK/JRE/JVM, variables, data types, operators, type casting, Scanner input, and practical exercises with solutions

☕ Java Fundamentals & Program Development

Class 1 Complete Notes | From Basics to Mini Project

📚 About this guide: Complete, exam-friendly notes for Java Class 1: Fundamentals & Program Development. Covers Programming Basics, JDK/JRE/JVM, Variables, Data Types, Operators, Scanner Input, Type Casting, and Practical Exercises with step-by-step code explanations.
1.1 - 1.3

Programming, Algorithms & Source Code

  • Programming: Writing instructions that tell a computer how to perform a task.
  • Algorithm: A step-by-step, language-independent procedure to solve a problem (like a recipe idea).
  • Program: The implementation of an algorithm in a specific language (like the recipe written in English).
  • Source Code: Human-readable text written by the programmer (saved as .java files).
1.4 - 1.5

Compiler, JDK, JRE & JVM

ComponentContainsUsed For
JVMBytecode interpreterExecuting bytecode ("Write Once, Run Anywhere")
JREJVM + LibrariesRunning Java programs
JDKJRE + Compiler (javac) + ToolsDeveloping and compiling programs

Flow: Main.java → (javac) → Main.class (bytecode) → (JVM) → Output

1.7 - 1.8

Syntax vs Semantics & Types of Errors

  • Syntax: Grammar rules of the language (e.g., missing semicolon).
  • Semantics: The actual meaning/logic of the code (e.g., wrong formula).
Error TypeDetected WhenExample
SyntaxCompile timeMissing ; or invalid variable name
RuntimeWhile runningDividing by zero (ArithmeticException)
LogicalChecking outputWrong formula (Compiles & runs, but gives wrong answer)
2.1

GUI vs CLI

  • GUI (Graphical User Interface): Interact using windows, icons, menus, and a mouse. (Easy for beginners).
  • CLI (Command Line Interface): Interact by typing text commands into a terminal. (Faster for developers, used for compiling/running).
2.3

Text Editors vs IDEs

FeatureText Editor (Notepad)IDE (IntelliJ, Eclipse)
Edit codeYesYes
Compile & RunManually via CLIBuilt-in button
Error detectionNoYes, live underlining
Auto-completeLimitedYes, smart suggestions
2.4

Popular Java IDEs

  • IntelliJ IDEA: Popular, smart code completion, very beginner-friendly (Community Edition is free).
  • Eclipse: Long-established, free, open-source, widely used in universities.
  • VS Code: Lightweight editor that becomes a Java IDE after installing the Java Extension Pack.
3.0

Hello World Program

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}
4.0

Line-by-Line Breakdown

  • public class Main: All Java code must be inside a class. If public, file name must match (Main.java).
  • public static void main(String[] args): The entry point. public (accessible anywhere), static (runs without creating an object), void (returns nothing), String[] args (command-line arguments).
  • System.out.println(): Prints text to the console and moves to a new line. (Use print() to stay on the same line).
🎯 Golden Rules: Every statement ends with ; | Java is case-sensitive | Blocks use {} | Text uses ""
5.1

Variables & Naming Rules

A variable is a named memory location that stores a value. Java is statically typed (must declare type).

Syntax: dataType variableName = value;

Rules: Can contain letters, digits, _, $. Cannot start with a digit. Cannot be a keyword. Use camelCase by convention.

5.2

Primitive vs Reference Data Types

TypeStoresSizeExample
intWhole numbers4 bytesint age = 25;
doubleDecimals (15 digits precision)8 bytesdouble price = 99.75;
floatDecimals (7 digits precision)4 bytesfloat temp = 36.5f; (Needs f)
charSingle character2 byteschar grade = 'A'; (Single quotes)
booleantrue or false1 bitboolean pass = true;
StringText (Class, not primitive)VariesString name = "Ali"; (Double quotes)
5.3

Constants (final keyword)

A constant's value cannot be changed after assignment. Use the final keyword. Convention: UPPERCASE_WITH_UNDERSCORES.

final double PI = 3.14159;
final int MAX_MARKS = 100;
// PI = 3.14;  ERROR: cannot assign a value to final variable
6.0

Getting User Input (Scanner)

import java.util.Scanner; // 1. Import

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in); // 2. Create object
        
        System.out.print("Enter your age: ");
        int age = input.nextInt(); // 3. Read input
        
        System.out.println("You are " + age + " years old.");
        input.close();
    }
}
⚠️ Common Pitfall: After nextInt(), the Enter key (newline) stays in the buffer. If you use nextLine() next, it will read an empty string. Fix: Add an extra input.nextLine(); to consume the leftover newline.
7.0

Arithmetic, Relational & Logical Operators

  • Arithmetic: +, -, *, / (Integer division drops decimals!), % (Modulus/Remainder).
  • Relational: == (Equal), != (Not equal), >, <, >=, <=. (Returns boolean).
  • Logical: && (AND), || (OR), ! (NOT).
  • Increment/Decrement: x++ (post-increment: use then increase), ++x (pre-increment: increase then use).
8.2

Automatic Conversion (Widening)

Java automatically converts a smaller type to a larger type without data loss.

Order: byte → short → int → long → float → double

int a = 10;
double b = 3; // 3 becomes 3.0 automatically
double result = a / b; // 10.0 / 3.0 = 3.333...
8.3

Explicit Conversion (Narrowing / Casting)

Converting a larger type to a smaller type must be done manually using a cast. Data may be lost (decimals are truncated, not rounded).

double price = 99.99;
int rounded = (int) price; // 99 (decimal part is cut off)

// int x = 7.5; ERROR: possible lossy conversion
int y = (int) 7.5; // OK, y = 7
8.4

Casting to Fix Integer Division

If you divide two integers, Java performs integer division. Cast before dividing to get a decimal result.

int total = 17;
int count = 5;

double wrong = total / count; // 3.0 (Integer division happened first!)
double correct = (double) total / count; // 3.4 (Cast applied first)
Ex 1-4

Quick Exercise Formulas

  • Area of Circle: PI * radius * radius
  • Area of Rectangle: length * width
  • Simple Interest: (principal * rate * time) / 100
  • Celsius to Fahrenheit: (celsius * 9.0 / 5) + 32 (Use 9.0 to avoid integer division!)
Mini Project

Student Marks Calculator

Accepts name and 3 subject marks, then calculates total, average, and pass/fail result.

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.print("Enter student name: ");
        String name = input.nextLine();

        System.out.print("Enter marks for subject 1: ");
        int m1 = input.nextInt();
        System.out.print("Enter marks for subject 2: ");
        int m2 = input.nextInt();
        System.out.print("Enter marks for subject 3: ");
        int m3 = input.nextInt();

        int total = m1 + m2 + m3;
        double average = total / 3.0; // 3.0 forces decimal division

        // Ternary operator (short if/else)
        String result = (average >= 40) ? "Pass" : "Fail";

        System.out.println("\n------ Result Sheet------");
        System.out.println("Name   : " + name);
        System.out.println("Total  : " + total);
        System.out.printf("Average: %.2f%n", average); // 2 decimal places
        System.out.println("Result : " + result);

        input.close();
    }
}

📌 Quick Revision Summary

⭐ Core Concepts:
🔄 Flow: .java (Source) → javac → .class (Bytecode) → JVM → Output
📦 JDK ⊃ JRE ⊃ JVM
🐛 Errors: Syntax (Compile), Runtime (Crash), Logical (Wrong Output)
🚪 Entry Point: public static void main(String[] args)
🔢 Types: int, double, float, char, boolean, String
⌨️ Input: Scanner (import java.util.Scanner;)
➗ Division: int/int drops decimals. Cast to double or use .0!
🔄 Casting: Widening (Auto, Safe) | Narrowing (Manual, Data Loss)

📝 Practice Questions

  • Q1: Differentiate between JDK, JRE and JVM.
  • Q2: What is the difference between a compile-time error and a logical error? Give one example of each.
  • Q3: Why is main declared static?
  • Q4: What is the output of System.out.println(7 / 2);? How would you get 3.5?
  • Q5: What is the value of x and y after int x = 5; int y = x++ + ++x;?
  • Q6: Write a program that reads a number of days and prints the equivalent number of weeks and remaining days (Hint: use / and %).

❓ Frequently Asked Questions (FAQ)

Q: What is the difference between JDK, JRE, and JVM? A: JVM (Java Virtual Machine) executes bytecode. JRE (Java Runtime Environment) includes the JVM and standard libraries needed to run programs. JDK (Java Development Kit) includes the JRE plus development tools like the compiler (javac) and debugger, which are needed to write and compile programs.
Q: What are the three types of errors in Java? A: 1. Syntax Errors: Violations of Java's grammar rules detected by the compiler (e.g., missing semicolon). 2. Runtime Errors: Illegal operations that crash the program while running (e.g., dividing by zero). 3. Logical Errors: The program runs without crashing but produces an incorrect result due to flawed logic.
Q: Why is the main method declared static in Java? A: The main method is declared static so that the JVM can call it directly using the class name without needing to create an object (instance) of the class first. This allows the program to start executing immediately.
Q: What is the difference between widening and narrowing in Java? A: Widening (Automatic Conversion) is when Java automatically converts a smaller data type to a larger one (e.g., int to double) without data loss. Narrowing (Explicit Casting) is when you manually convert a larger type to a smaller one (e.g., double to int) using a cast, which may result in data loss.
🎓 SRI LANKA ONLINE ICT TRAINING

Expert ICT, Computer Science, Coding & Digital Marketing Classes

Learn ICT, Computer Science, Programming, Web Development and Digital Marketing with practical, career-focused guidance.

💬 Join WhatsApp ▶ Watch Tutorials

🚀 Learn Today. Build Tomorrow.

Welcome to our Sri Lanka Online ICT & Computer Classes community! We provide Online Tuition Classes, Home Visit Classes and Individual / Group Classes for students and professionals. Whether you are a school student, university student, beginner programmer or entrepreneur, we help you develop practical IT skills for education and career growth.

💡 Explore Our Training & Services

🎓 University Project Guidance

Technical guidance for university assignments and final-year IT projects.

  • BIT / BSc / IT / ICT Projects
  • Final Year Project Guidance
  • PHP & MySQL Projects
  • Python & Java Projects
  • Database & Web Applications
  • Project Ideas & Documentation

🤖 AI, Coding & Software

Develop programming knowledge and practical software development skills.

  • Python Programming
  • C & Java Programming
  • PHP & JavaScript
  • HTML & CSS
  • jQuery & AJAX
  • AI & Smart Applications

🏫 School ICT Classes

Interactive ICT and Computer Science lessons for school students.

  • Grade 1 – Grade 11
  • G.C.E. O/L ICT
  • G.C.E. A/L ICT
  • GIT Classes
  • School ICT & Internal Tests
  • Past Papers & Revision

🌐 Web Design & Development

Build websites and database-driven applications for individuals and businesses.

  • Website Design
  • Website Development
  • WordPress Development
  • PHP & MySQL
  • HTML / CSS / JavaScript
  • Website SEO & Maintenance

📢 Digital Marketing

Grow your brand online with social media and digital marketing support.

  • Digital Marketing
  • Facebook Page Management
  • Instagram Marketing
  • TikTok & YouTube
  • Content Creation & SEO
  • Facebook Ads & Reels

💻 Computer & IT Skills

Build essential computer skills from absolute beginner to advanced level.

  • Computer Fundamentals
  • MS Word, Excel & PowerPoint
  • Excel Formulas & Macros
  • Oracle / MySQL / MS SQL
  • AWS, Linux & DevOps
  • Freelancing & IT Skills

📚 Learn With Your Curriculum

Support for Sri Lankan Local Curriculum, Cambridge and Pearson Edexcel programs.

🇱🇰 Sri Lankan Local Curriculum

  • Grade 01 – Grade 11 ICT
  • G.C.E. O/L ICT
  • G.C.E. A/L ICT
  • GIT Classes
  • Term Test Preparation
  • Model Papers & Notes
  • English / Sinhala / Tamil Medium

📘 Pearson Edexcel

  • iPrimary Computing
  • iLowerSecondary Computing
  • International GCSE ICT
  • International GCSE Computer Science
  • GCSE Computer Science
  • International A Level IT
  • International A Level Computer Science

📗 Cambridge Curriculum

  • Cambridge Primary Computing
  • Cambridge Lower Secondary Computing
  • Cambridge IGCSE ICT
  • Cambridge IGCSE Computer Science
  • Cambridge O Level Computer Science
  • AS & A Level IT
  • AS & A Level Computer Science

💻 Programming & Software Development

🛠️ Programming Languages & Technologies

✅ Python Programming ✅ C Programming ✅ Java Programming
✅ PHP Programming ✅ JavaScript ✅ HTML & CSS
✅ jQuery & AJAX ✅ ASP.NET ✅ VB.NET
✅ VB6 ✅ MySQL ✅ MS SQL Server
✅ MS Access ✅ Oracle Database ✅ Database Design
✅ SQL Queries ✅ Database Programming ✅ Software Development

🌐 Web Design & Development

  • ✅ Website Design
  • ✅ Website Development
  • ✅ WordPress Website Development
  • ✅ HTML / CSS / JavaScript
  • ✅ PHP & MySQL
  • ✅ WordPress SEO
  • ✅ Website Maintenance
  • ✅ Web Applications
  • ✅ Database-Driven Websites

🎓 University & Final Year IT Projects

🧑‍💻 Project Development

  • BIT / BSc / IT / ICT Projects
  • PHP & MySQL Projects
  • Python Projects
  • Java Projects
  • Web Application Projects
  • Database Projects

📄 Documentation & Practical

  • Project Ideas
  • System Architecture
  • Database Design
  • Assignments Guidance
  • Practical Implementation
  • Technical Documentation

🧠 AI & Smart Applications

  • AI Application Concepts
  • Machine Learning Modules
  • Automation Applications
  • Step-by-Step Coding
  • System Implementation
  • Project Learning Support

📊 Database, Cloud & IT Training

✅ Oracle Database ✅ MySQL ✅ Microsoft SQL Server
✅ Microsoft Access ✅ Database Design ✅ SQL Queries
✅ AWS Cloud ✅ Linux ✅ UNIX
✅ Windows Server ✅ DevOps ✅ SRE
✅ Automation ✅ Software Testing ✅ Freelancing Skills

📱 Digital Marketing & Social Media

✅ Digital Marketing ✅ Facebook Page Setup & Management
✅ Instagram Marketing ✅ TikTok Marketing
✅ YouTube Channel Setup ✅ Social Media Management
✅ Content Creation ✅ SEO
✅ Facebook Ads ✅ Instagram Reels
✅ LinkedIn Branding ✅ Social Media Campaign Planning
✅ Hashtag Strategy ✅ Insights & Engagement

🖥️ Microsoft Office & Digital Skills

  • ✅ MS Word
  • ✅ MS Excel
  • ✅ MS PowerPoint
  • ✅ Excel Formulas
  • ✅ Excel Automation & Macros
  • ✅ Computer Fundamentals
  • ✅ Digital Literacy
  • ✅ Multimedia Presentations

⭐ Why Join Our Classes?

🌍
Online & Home Visit Classes
👥
Individual & Group Classes
🗣️
English / Sinhala / Tamil
📚
School & University Support
📝
Past Papers & Model Papers
💻
Practical Programming
🚀
Beginner to Advanced Skills
🎯
Career-Focused Learning

📞 Ready to Start Learning?

Book your online class or contact us for ICT training, programming courses, university project guidance and digital marketing services.

📱 Call / WhatsApp: +94 729622034

📧 Email: itclasssl@gmail.com

💻 Skype: ITClassSL

💬 Contact Us on WhatsApp

🌐 Our Online Learning Platforms

Explore tutorials, notes, project guides and learning resources.

📺 YouTube Tutorials
Watch ICT & programming videos
💬 WhatsApp Community
Join our learning community
✍️ ICT Blog
Computer classes and tutorials
📰 WordPress
Notes and learning resources
📘 Facebook
Follow our official page
🌐 Wix Website
Explore our training services
💻 eTeacher Website
Online learning platform
📝 Medium
Read technology articles
❓ Quora
Project guidance and Q&A
🎓 Strikingly Portfolio
University project resources
🗣️ ElaKiri Forum
Join the project discussion
🎵 TikTok
Follow our learning videos
🛒 Payhip
Explore our digital resources
🌐 Weebly
Project and IT resources

ITClassSL — ICT Training | Computer Classes | Programming | University Project Guidance | Digital Marketing

Learn • Practice • Build • Grow 🚀

Wednesday, September 30, 2026

Python Casting, int() float(), Python Flowcharts, BIDMAS Python, Order of Operations, Python Error Detection, Test Plans, ICT Programming Cambridge-Lower-Secondary-Computing-7-Ben-Barnes-Tristan-Kirkpatrick

🐍 Python: Casting, Flowcharts, BIDMAS & Errors

Data Types, Planning, Order of Operations & Debugging

📚 About this guide: Complete, exam-friendly notes for Advanced Python Programming. Master data type casting (int/float), create flowcharts and algorithms, understand BIDMAS order of operations, and learn error detection with test plans.
Concept 1

What is Casting?

Casting is the process of ensuring data is set to the correct data type. In Python, when the user inputs data and it is stored in a variable, you need to inform the program what type of data it is.

⚠️ Important: The input() function captures user input as a string data type. If you want to perform calculations, you must cast it to int() or float().
Problem Example

Without Casting (Wrong Result)

num1 = input("Enter a number: ")
answer = num1 * 2
print("The answer is", answer)
          
❌ Output when entering 5: The answer is 55

Why? Python treats num1 as a string, so "5" * 2 becomes "55" (string repetition), not 10.

Solution

With Casting (Correct Result)

CodeWhat it does
num1 = int(input("Enter a number: ")) Casts input to an integer (whole number)
num1 = float(input("Enter a number: ")) Casts input to a float (decimal number)
num1 = int(input("Enter a number: "))
answer = num1 * 2
print("The answer is", answer)
          
✅ Output when entering 5: The answer is 10
Keyword

Essential Vocabulary

  • Casting: The process of ensuring data is set to the correct data type
Exercise 1

Fix MealCost.py

Original Code (with errors):

money = input("How much money do you have? ")
meal = input("How much did the meal cost? ")
left = money - meal
print("After your meal you have,", left, "left.")
          
✅ Corrected Solution:
money = float(input("How much money do you have? "))
meal = float(input("How much did the meal cost? "))
left = money - meal
print("After your meal you have,", left, "left.")
            
Exercise 2

Rabbit Age Calculator

A rabbit's age is approximately 9 times the age of a human. Create a program that calculates rabbit age.

✅ Python Solution:
age = int(input("Enter the age of the rabbit: "))
rabbitAge = age * 9
print("The age of the rabbit in rabbit years is", rabbitAge)
            
Exercise 3

Square Area Calculator

Ask user for the length of one side of a square and calculate the area.

✅ Python Solution:
length = int(input("Enter the length of one side of a square: "))
area = length * length
print("The area of the square is:", area)
            
Exercise 4

Car Speed Calculator

Calculate speed using distance and time (Speed = Distance ÷ Time).

✅ Python Solution:
distance = int(input("Enter the distance in meters: "))
time = int(input("Enter the time in seconds: "))
speed = distance / time
print("The car was travelling at a speed of", speed, "meters per second")
            

Note: Use float() instead of int() if you want decimal precision for the inputs.

Concept 2

Planning with Flowcharts

To code a calculation program, you first need to plan. This allows you to break down the problem and work through a solution. A common method is creating a flowchart.

Symbols

Key Flowchart Symbols

SymbolShapePurpose
Start/StopOvalUsed at the start and end of the flowchart
ProcessRectangleUsed when something needs to happen (e.g., calculations)
Input/OutputParallelogramUsed when data needs to be input or output
Example

Flowchart → Python Code

Flowchart Steps:

  • Start
  • INPUT number1
  • INPUT number2
  • total = number1 + number2
  • OUTPUT "The total of the two numbers is", total
  • Stop
✅ Python Implementation:
number1 = int(input("Enter your first number: "))
number2 = int(input("Enter your second number: "))
total = number1 + number2
print("The total of the two numbers is:", total)
            
Practice

Create a Flowchart & Python Program

Task: Create an algorithm that:

  • Asks the user to input two numbers
  • Adds the two numbers together and divides by 2 to find the mean average
  • Outputs the average
✅ Python Solution:
number1 = float(input("Enter the first number: "))
number2 = float(input("Enter the second number: "))
average = (number1 + number2) / 2
print("The average is:", average)
            

Test Cases:

  • number1 = 7, number2 = 9 → average should be 8
  • number1 = 15, number2 = 20 → average should be 17.5
Keywords

Essential Vocabulary

  • Algorithm: A sequence of steps or instructions to solve a problem
  • Flowchart: A diagram showing the sequence of actions in a computer program; a graphical representation to show the steps to solve a problem
  • Syntax: The structure of the code used in a programming language
Concept 3

What is BIDMAS?

BIDMAS is an acronym to help you remember the order of operations when completing mathematical calculations. A program will carry out calculations in this order:

LetterOperationExample
BBrackets(10 - 6)
IIndices2³ = 2 × 2 × 2 = 8
DDivision10 / 2
MMultiplication5 * 3
AAddition7 + 3
SSubtraction10 - 4
⚠️ Important: Addition and subtraction are equal priority, so if both appear, they are calculated from left to right.
Examples

BIDMAS in Action

CalculationOutcomeReason
3 + 4 * 5234 * 5 calculated first, then add 3
2 * 7 + 3 * 5292*7 and 3*5 calculated first, then added
6 + 3 * 9 / 118.459/11 first, then *3, then +6
20 * (10 - 6) / 516Brackets first (4), then *20, then /5
Practice

BIDMAS Practice Table

Complete the table by adding brackets to get the desired answer:

CalculationAnswerDesired AnswerCorrected Calculation
5 * 8 + 646705 * (8 + 6)
35 - 10 + 15104035 - (10 + 15) or (35 - 10) + 15
9 + 3 * 52460(9 + 3) * 5
9 * 8 - 20 / 56810.4(9 * 8 - 20) / 5
60 * 40 - 3 * 48225688060 * (40 - 3) * 48 (needs review)
18 * 6 - 2 / 8107.759(18 * 6 - 2) / 8
Keyword

Essential Vocabulary

  • BIDMAS: An acronym to help you remember the order of operations: Brackets, Indices, Division, Multiplication, Addition, Subtraction
Concept 4

Test Plans

A test plan is used to check whether a program is working correctly. It contains tests showing what is expected to happen (expected outcome).

Test #Data EnteredExpected OutcomeActual OutcomePass/Fail
1num1=20, num2=15total = 35total = 300❌ Fail
2num1=19, num2=34total = 53total = 646❌ Fail
🔍 Error Identified: The program is not working as expected. The arithmetic operator is wrong (likely using * instead of +).
Common Errors

1. Missing Brackets

Incorrect CodeIssueCorrect Code
print("Hello World" Missing close bracket at end print("Hello World")
num1 = int(input("Enter a number:") Two open brackets, only one close num1 = int(input("Enter a number:"))
Common Errors

2. Missing Quotation Marks

Incorrect CodeIssueCorrect Code
name = input(Enter a name") Missing quotation mark before "Enter" name = input("Enter a name")
print("The name you entered was,name) Missing quotation mark after "was" print("The name you entered was", name)
print("The name you entered was,name") Quotation marks in wrong place print("The name you entered was", name)
Debugging Tips

How to Find and Fix Errors

  • Read error messages carefully - Python tells you the line number and type of error
  • Check brackets - Every opening bracket needs a closing bracket
  • Check quotation marks - Every string needs matching quotes
  • Check spelling - Python is case-sensitive (print not Print)
  • Test with different inputs - Use a test plan to verify expected outcomes

❓ Frequently Asked Questions (FAQ)

Q: What is casting in Python? A: Casting is the process of ensuring data is set to the correct data type. In Python, the input() function captures data as a string, so you must cast it to int() for whole numbers or float() for decimal numbers before performing calculations.
Q: What is the difference between int() and float() in Python? A: int() converts data to an integer (whole number), while float() converts data to a floating-point number (decimal number). Use int() for counting and float() for measurements or calculations requiring decimals.
Q: What does BIDMAS stand for in programming? A: BIDMAS stands for Brackets, Indices, Division, Multiplication, Addition, Subtraction. It defines the order of operations in mathematical calculations. Addition and subtraction are equal priority and calculated left to right.
Q: What is a test plan in Python programming? A: A test plan is a document used to check whether a program is working correctly. It contains test numbers, data entered, expected outcomes, actual outcomes, and pass/fail status to identify and debug errors in the code.
Q: Why does "5" * 2 give "55" instead of 10 in Python? A: Because input() captures data as a string, "5" * 2 performs string repetition (repeating the string "5" twice), resulting in "55". To get 10, you must cast the input to int() first: int("5") * 2 = 10.

Saturday, September 26, 2026

GCE A/L ICT Competency 9.1 - Algorithms & Python Tamil Medium Online Class Algorithms + Python Programming | Problem Solving to Execution | Theory + Code + Exam Patterns

🟦 GCE A/L ICT – Competency 9

Algorithms + Python Programming | Problem Solving to Execution | Theory + Code + Exam Patterns

GCE A/L ICT - UNIT 9: PROGRAMMING


1. Fundamentals of Problem Solving & Algorithm Design

   1.1. Concept of Problem Solving

   1.2. Identification of Inputs, Processes, and Outputs (IPO)

   1.3. Step-by-Step Approach to Problem Solving

   1.4. Representation of Algorithms

        1.4.1. Flowcharts (Standard Symbols: Terminal, Input/Output, Process, Decision, Flowlines)

        1.4.2. Pseudo-code (Structured Keywords: IF-THEN-ELSE, WHILE, FOR)


2. Introduction to Programming Languages

   2.1. Evolution of Programming Languages (Low-level vs. High-level)

   2.2. Translators: Compilers, Interpreters, and Assemblers

   2.3. Characteristics of the Python Programming Language


3. Basic Syntax and Coding Fundamentals in Python

   3.1. Python Coding Environment (IDLE, Script Mode vs. Interactive Mode)

   3.2. Identifiers, Keywords, and Naming Conventions

   3.3. Variables and Assignment Statements

   3.4. Basic Data Types

        3.4.1. Integer (int)

        3.4.2. Floating-point (float)

        3.4.3. String (str)

        3.4.4. Boolean (bool)

   3.5. Operators and Expressions

        3.5.1. Arithmetic Operators (+, -, *, /, //, %, **)

        3.5.2. Relational / Comparison Operators (==, !=, >, <, >=, <=)

        3.5.3. Logical Operators (and, or, not)

   3.6. Basic Input and Output Functions (input() and print())


4. Control Structures

   4.1. Sequence Control Structure

   4.2. Selection / Decision-Making Structures

        4.2.1. Simple 'if' statement

        4.2.2. 'if - else' statement

        4.2.3. Nested 'if' and 'if - elif - else' chains

   4.3. Iteration / Looping Structures

        4.3.1. Condition-controlled loops ('while' loop)

        4.3.2. Count-controlled loops ('for' loop with range() function)

        4.3.3. Nested Loops

        4.3.4. Loop control statements (break, continue)


5. Python Data Structures (Collections)

   5.1. Strings (Indexing, Slicing, and String Methods)

   5.2. Lists (Creating, Indexing, Mutable properties, List Methods)

   5.3. Tuples (Immutable sequences)

   5.4. Dictionaries (Key-Value pairs, Accessing and Modifying keys)


6. Functions and Modularity

   6.1. Concept of Modular Programming

   6.2. Built-in Functions vs. User-defined Functions

   6.3. Function Definition (def keyword) and Arguments/Parameters

   6.4. Return Values (return statement)

   6.5. Scope of Variables: Local vs. Global Variables


7. File Handling

   7.1. Concept of Data Persistence

   7.2. Opening and Closing Files (open(), close())

   7.3. File Access Modes ('r' for Read, 'w' for Write, 'a' for Append)

   7.4. Reading from Text Files (read(), readline(), readlines())

   7.5. Writing data to Text Files (write(), writelines())


8. Error and Exception Handling

   8.1. Types of Programming Errors (Syntax, Runtime, Logical Errors)

   8.2. Handling Exceptions using 'try - except' blocks


9. Database Connectivity (Python with SQLite)

   9.1. Establishing a Database Connection

   9.2. Executing SQL queries via Python Scripting (CRUD Operations)


10. Standard Algorithms in Python

    10.1. Implementing Linear Search

    10.2. Implementing Bubble Sort


Algorithms Python Basics Control Structures Functions Data Structures Search & Sort
📘 Competency 9 Overview | Problem-Solving Process ▼
Competency என்ன சொல்கிறது?
“Develops algorithms to solve problems and uses Python programming language to encode algorithms.”

அதாவது: Problem → Algorithm → Flowchart/Pseudocode → Python Program → Testing/Debugging

ஒரு programming question வந்தால், நேரடியாக Python எழுதுவது மட்டும் போதாது. முதலில் problem-ஐ புரிந்துகொண்டு, solution-ஐ திட்டமிட்டு, algorithm உருவாக்கி, பின்னர் அதை Python-ல் எழுத வேண்டும்.

9.1 Problem-Solving Process (4 Stages)

1. Understanding

பிரச்சினையைப் புரிந்துகொள்ளுதல் (Input, Output, Conditions)

2. Defining

பிரச்சினை மற்றும் அதன் எல்லைகளை (boundaries) வரையறுத்தல்

3. Planning

தீர்வைத் திட்டமிடுதல் (Algorithm/Flowchart)

4. Implementation

தீர்வை Python-ல் செயல்படுத்துதல்

📝 Exam Question

Q: பிரச்சினை தீர்க்கும் செயல்முறையின் நான்கு முக்கிய படிகளை எழுதுக.

Answer:
  1. பிரச்சினையைப் புரிந்துகொள்ளுதல்
  2. பிரச்சினை மற்றும் அதன் எல்லைகளை வரையறுத்தல்
  3. தீர்வைத் திட்டமிடுதல்
  4. தீர்வை செயல்படுத்துதல்
🏗️ 9.2 Top-Down Design & Stepwise Refinement ▼

Modularization

ஒரு பெரிய problem-ஐ சிறிய, manageable modules-ஆக பிரிப்பது. (Eg: School System → Student, Attendance, Exams)

Top-Down Design

Big problem → Small problems. மேலிருந்து கீழாக problem-ஐ பிரிப்பது.

Stepwise Refinement

ஒரு பெரிய task-ஐ தொடர்ந்து சிறிய tasks-ஆக detail-ஆக பிரித்துக் கொண்டே செல்வது.

Structure Chart Example

Student Result | ------------------------- | | | Input Calculate Output | --------------- | | Total Average
📝 Exam Question

Q: Top-down design என்றால் என்ன?

Answer: ஒரு பெரிய பிரச்சினையை முதலில் முக்கிய modules-ஆகவும், பின்னர் அவற்றை சிறிய sub-modules-ஆகவும் பிரித்து தீர்வு காணும் முறையே Top-down design ஆகும்.
🧠 9.3 Algorithmic Approach | Flowchart & Pseudocode ▼

Algorithm என்பது ஒரு problem-ஐ solve செய்வதற்கான finite, clear, ordered steps ஆகும்.

Algorithm-ன் 5 Characteristics

1. Finiteness

ஒரு கட்டத்தில் முடிவடைய வேண்டும்.

2. Definiteness

ஒவ்வொரு step-உம் தெளிவாக இருக்க வேண்டும்.

3. Input

Input இருக்கலாம் (zero or more).

4. Output

Result/output கண்டிப்பாக கொடுக்க வேண்டும்.

5. Effectiveness

Practical-ஆக execute செய்யக்கூடியதாக இருக்க வேண்டும்.

Flowchart Symbols

Symbolபயன்பாடு
OvalStart / Stop
RectangleProcess
ParallelogramInput / Output
DiamondDecision
ArrowFlow direction

Pseudocode Example (Largest of 2 numbers)

START INPUT A INPUT B IF A > B THEN OUTPUT A ELSE OUTPUT B END IF STOP

Hand Trace Example

a = 5 b = 3 c = a + b print(c)
StepabcOutput
Initial53--
c=a+b538-
print(c)5388
⭐ Past Paper Pattern (2022 Paper II Q8a)
123 என்ற எண்ணை 321 ஆக reverse செய்யும் logic:
n = int(input()) reverse = 0 while n > 0: digit = n % 10 reverse = reverse * 10 + digit n = n // 10 print(reverse)
🧩 9.4 Programming Paradigms & Generations ▼

Imperative

"How to do?"
Computer என்னென்ன steps செய்ய வேண்டும் என்று programmer கூறுவார். (Eg: Python loops)

Declarative

"What should be done?"
எப்படி செய்ய வேண்டும் என்பதை விட என்ன result வேண்டும் என்பதில் focus. (Eg: SQL)

Object-Oriented

Program-ஐ objects மற்றும் classes அடிப்படையில் அமைப்பது. (Eg: Python classes)

Programming Language Generations

GenerationNameExample
1GLMachine languageBinary (0s, 1s)
2GLAssemblyAssembly Language
3GLHigh-levelC, Java, Python
4GLVery high-levelSQL, MATLAB
⚙️ 9.5 Program Translation (Compiler vs Interpreter) ▼

Computer நேரடியாக high-level Python statements-ஐ execute செய்யாது. எனவே translation தேவை.

Compiler

முழு source program-ஐ ஒரே நேரத்தில் translate செய்கிறது. Execution வேகம் அதிகம். Object code உருவாகும்.

Interpreter

Program-ஐ line-by-line translate மற்றும் execute செய்கிறது. Python பொதுவாக இதைப் பயன்படுத்துகிறது.

Linker

பல object modules / libraries-ஐ ஒன்றாக இணைத்து executable program உருவாக்க உதவுகிறது.

Compiler vs Interpreter

CompilerInterpreter
Whole program at onceStatement/line at a time
Faster executionGenerally slower
Produces Object codeNo standalone object code
Errors reported after compilationErrors appear during execution
🐞 9.6 IDE & Debugging (3 Types of Errors) ▼

IDE (Integrated Development Environment) என்பது Code editor, Run/Execute, Debugger போன்ற tools-ஐ ஒரே environment-ல் வழங்குவது.

3 முக்கிய Errors

1. Syntax Error

Grammar தவறு. Program run ஆகாது.

if x > 5 (: missing)

2. Runtime Error

Program run செய்யும்போது crash ஆகும்.

x = 10 / 0 (Division by zero)

3. Logical Error

Program execute ஆகும். ஆனால் answer தவறாக இருக்கும்.

area = length + width (Should be *)

🐍 9.7 Python Basics | Variables, Types & Operators ▼

Basic Structure & Data Types

# Get two numbers (Comment) a = int(input("Enter A: ")) # Input & int type b = int(input("Enter B: ")) total = a + b # Processing print(total) # Output

int

age = 18

float

price = 25.50

str

name = "Ali"

bool

passed = True

Operators & Precedence

  • Arithmetic: +, -, *, /, %, **, //
  • Relational: >, <, >=, <=, ==, !=
  • Logical: and, or, not
Precedence Example:
result = 2 + 3 * 4 → First 3*4=12, then 2+12=14.
(2 + 3) * 4 → Answer = 20
🔀 9.8 Control Structures (Sequence, Selection, Repetition) ▼

1. Sequence

Statements order-ஆக execute ஆகும்.
a=10
b=20
c=a+b

2. Selection

Condition அடிப்படையில் decision.
if marks >= 50:
  print("Pass")
else:
  print("Fail")

3. Repetition

Looping statements.
for i in range(1, 6):
  print(i)

Nested Control Structure

for i in range(1, 6): if i % 2 == 0: print(i) # Prints 2, 4
⭐ Exam Question

Q: Control structures மூன்றை எழுதுக.
Answer: 1. Sequence, 2. Selection, 3. Repetition
🧱 9.9 Sub-programs / Functions ▼
# User-defined Function def add(a, b): # a, b are Parameters return a + b answer = add(10, 20) # 10, 20 are Arguments print(answer) # Output: 30

Local vs Global Variables

LocalGlobal
Function-க்குள் உருவாக்கப்படுகிறதுProgram-க்கு வெளியே உருவாக்கப்படுகிறது
Scope limited to functionWider scope (entire program)
⭐ Past Paper Pattern (2022 Paper II Q8b)
Q: Student name & food item-ன் முதல் மற்றும் கடைசி எழுத்துகள் ஒரே மாதிரியா என பரிசோதிக்கும் function.
def Party(studentName, foodItem): return studentName[0] == foodItem[0] and \ studentName[-1] == foodItem[-1] # Party("Kamal", "Kebab") -> 'K'=='K' but 'l'!='b' -> False
📦 9.10 Data Structures (Strings, Lists, Tuples, Dicts) ▼

String

name = "Python"
Index: name[0] is 'P', name[-1] is 'n'

List

nums = [10, 20]
Mutable (changeable).
Methods: append(), pop(), sort()

Tuple

nums = (10, 20)
Immutable (cannot change).

Dictionary

std = {"name": "Ali", "age": 18}
Key-value pairs. std["name"]

⭐ Past Paper Pattern (2022 Paper I Q40)
List operations trace:
numbers = [10, 20, 30, 40, 50] numbers.pop(1) # Removes 20 -> [10, 30, 40, 50] numbers.append(60) # Adds 60 -> [10, 30, 40, 50, 60] numbers.pop(2) # Removes 40 (index 2) -> [10, 30, 50, 60] print(numbers) # Answer: [10, 30, 50, 60]
💾 9.11 & 9.12 File Handling + Database (SQL) ▼

File Handling Modes

ModeMeaning
"r"Read
"w"Write (Overwrites existing data ⚠️)
"a"Append (Adds to end of file)

Database CRUD Operations (SQL)

Create (Insert)

INSERT INTO Student VALUES (101, 'Ali');

Read (Select)

SELECT * FROM Student;

Update

UPDATE Student SET name='Ahmed' WHERE id=101;

Delete

DELETE FROM Student WHERE id=101;

🔍 9.13 Searching and Sorting (Sequential & Bubble) ▼

Sequential Search

Data ஒன்றை ஒன்றாக sequentially check செய்வது.

numbers = [15, 8, 23, 10, 7] search = 10 for x in numbers: if x == search: print("Found") break

Bubble Sort (Ascending)

Adjacent elements-ஐ compare செய்து order தவறாக இருந்தால் swap செய்வது.

numbers = [5, 2, 8, 1] n = len(numbers) for i in range(n): for j in range(0, n-i-1): if numbers[j] > numbers[j+1]: # Swap using temp variable temp = numbers[j] numbers[j] = numbers[j+1] numbers[j+1] = temp print(numbers) # [1, 2, 5, 8]
Dummy (Temp) Variable ஏன்?
இரண்டு values-ஐ swap செய்யும்போது ஒரு value-ஐ பாதுகாப்பாக வைத்திருக்க temp பயன்படுகிறது.
Python shortcut: a, b = b, a
🏆 Exam Priority & 5-Way Problem Solving Trick ▼

🔥 Exam Focus Priority

PrioritySection
🔥🔥🔥 மிக முக்கியம்9.3 Algorithms, 9.7 Python basics, 9.8 Control structures, 9.9 Functions, 9.10 Data structures
🔥🔥 முக்கியம்9.13 Search & Bubble sort, 9.5 Translators, 9.2 Top-down
🔥 Theory9.11 Files, 9.12 Database (SQL), 9.6 IDE, 9.4 Paradigms
🧠 மிகவும் முக்கியமான Exam Connection (Even/Odd)
ஒரே problem-ஐ 5 விதமாக எழுதத் தெரிந்திருக்க வேண்டும்:

1. Algorithm

START
INPUT N
IF N MOD 2 = 0 THEN
  OUTPUT "Even"
ELSE
  OUTPUT "Odd"
END IF
STOP

2. Pseudocode

READ N
IF N % 2 == 0 THEN
  PRINT "Even"
ELSE
  PRINT "Odd"

3. Python Code

n = int(input())
if n % 2 == 0:
  print("Even")
else:
  print("Odd")

4. Flowchart

Start → Input N → Diamond (N%2==0?) → Yes (Even) / No (Odd) → Stop

5. Hand Trace (N=7)

n = 7
n % 2 = 1
Condition (1==0) is False
Output: Odd

🎓 Expert ICT, Coding, School Classes, Digital Marketing & University Project Guidance

Struggling with your university final year project? Want to master coding, upscale your business with expert digital marketing, or learn absolute computer basics from scratch? We offer high-quality individual and group online classes conducted in English, Sinhala, or Tamil mediums. Get guaranteed academic success and professional growth with tailored guidance.


🎓 University Final Year Project Guidance & AI

Get specialized, end-to-end mentoring and technical support to pass your degree or master's program with flying colors:

  • 🏫 Targeted Institutes: Expert guidance tailored for BIT UCSC, UoM, SLIIT, NIBM, and other leading universities.
  • 🔬 Postgraduate Support: Comprehensive assistance for MSc Software Final Year Projects.
  • 🤖 AI & Smart Applications: Step-by-step implementation of AI, Machine Learning (ML), and automation modules.
  • ✅ Guaranteed Success: Help with documentation, system architecture, coding, and viva preparation.

🏫 School ICT & Corporate Beginner Classes

  • 💻 Non-IT Staff Computer Basics: Absolute beginner-friendly online classes covering essential computer skills, office tools, and internet operations.
  • 🎒 Primary & Secondary (Grades 1-10): Interactive online ICT classes tailored to build strong foundations from early ages.
  • 📝 Exam Prep: Dedicated training packages for GCE O/L, GCE A/L ICT, and GIT exams.
  • 🌍 Global Syllabuses: Complete curriculum coverage for Local, Edexcel, and Cambridge in English & Tamil Mediums.

📢 Software Development & Digital Marketing Services

  • ⚙️ Software & Web Development: Professional custom software application and website development built using PHP & MySQL.
  • 🎯 Social Media Management: Content creation, publishing, and channel management for Facebook, Instagram, TikTok, and YouTube.
  • 📈 Ad Boosting: Highly targeted paid advertising campaigns to drive leads, traffic, and sales to your business.

📞 Connect With Us Instantly

Book your slot for online classes or get a premium tech service quote today!

💬 WhatsApp: +94 729622034

📧 Email: ITClassSL@gmail.com


🌐 Explore Our Resources & Communities

Stay updated with our latest tutorials, project ideas, and student guides across all our official platforms: