SS3 DIGITAL TECHNOLOGY First Term Week 5

INTRODUCTION TO PROGRAMMING Lesson Note

For SS3 DIGITAL TECHNOLOGY · First Term

Learning Objectives

This SS3 DIGITAL TECHNOLOGY lesson note covers INTRODUCTION TO PROGRAMMING for First Term, Week 5.

02

Lesson Note

Learning Objectives

By the end of the lesson, students should be able to:

•

Define programming.

•

Explain the meaning of a programming language.

•

Identify different types of programming languages.

•

State examples of programming languages.

•

Explain the importance of programming.

•

Differentiate between a program and a programming language.

•

Explain the meaning of source code and object code.

•

Describe the basic stages involved in program development.

•

Explain basic programming concepts such as variables, constants, data types and operators.

•

Identify common errors in computer programs

A. MEANING OF PROGRAMMING

Programming is the process of designing and writing instructions that tell a computer how to perform a particular task or solve a problem.

A computer does not normally understand ordinary human language directly. Therefore, programmers use programming languages to write instructions that can be translated into a form the computer can execute.

For example, a programmer may write a program that instructs a computer to:

*Calculate students’ scores.

*Display a message.

*Store students’ records.

*Perform mathematical calculations.

*Process examination results.

*Control a machine or device.

*Create a website or mobile application.

Simple Programming Process

Problem → Algorithm → Program Code → Translation → Execution → Output

B. What is a Program?

A program is a set of instructions written to make a computer perform a specific task.

For example, a calculator application is a program designed to perform calculations.

A program may be very simple, such as one that adds two numbers, or very complex, such as software used by banks, hospitals or large organizations.

C. What is a Programming Language?

A programming language is a formal language used by programmers to communicate instructions to a computer.

Programming languages provide rules and symbols for writing computer programs.

Examples of Programming Languages

Some common programming languages include:

*Python

*Java

*JavaScript

*C

*C++

*C#

*PHP

*Visual Basic

*Swift

*Kotlin

*Ruby

Different programming languages are designed for different purposes, although many can be used for several types of applications.

D. Types of Programming Languages

Programming languages can be classified in several ways. One common classification is based on their level of abstraction.

1. Low-Level Languages

Low-level languages are programming languages that are close to the machine’s hardware and instruction set.

They include:

a. Machine Language

Machine language consists of instructions represented in binary digits (0s and 1s) that the computer’s processor can execute directly.

Example:

10110000 01100001

Machine language is difficult for humans to read and write.

Advantages

1. Directly understood by the processor.

2. Very fast execution.

3. Gives programmers close control over hardware.

Disadvantages

1. Difficult to write.

2. Difficult to understand.

3. Difficult to debug.

4. Machine-dependent.

b. Assembly Language

Assembly language uses symbolic instructions instead of writing everything directly as binary.

Examples of assembly instructions include:

MOV, ADD, SUB, JMP

An assembler translates assembly language into machine code.

2. High-Level Languages

High-level languages are designed to be easier for humans to read, understand and write.

Examples include:

*Python

*Java

*C++

*C#

*JavaScript

*PHP

*Visual Basic

For example, a high-level language can contain an instruction such as:

PRINT “Hello”

This is easier for humans to understand than a sequence of binary instructions.

Advantages of High-Level Languages

•

Easy to learn and understand.

•

Easier to write programs.

•

Easier to debug.

•

Programs can often be developed more quickly.

•

Many provide libraries and tools that simplify programming.

•

Some are portable across different computer systems.

E. Comparison Between Low-Level and High-Level Languages

Low-Level Language  High-Level Language

Close to computer hardware  Closer to human language

More difficult to learn  Easier to learn

Machine language and assembly are examples Python, Java and C++ are examples

Requires detailed knowledge of hardware Requires less hardware knowledge

Generally less portable  Generally more portable

Can provide fine hardware control  Provides higher-level abstractions

F. TRANSLATORS

Computers need machine instructions to execute programs. Therefore, many programs written in high-level or assembly languages must be translated.

The major translators are:

1. Compiler

A compiler translates a complete program written in a high-level language into machine code or another lower-level form before execution.

Examples of languages commonly associated with compiled implementations include C and C++.

2. Interpreter

An interpreter translates and executes program instructions during program execution, often step by step.

Python and JavaScript can be used with interpreter-based execution environments.

3. Assembler

An assembler translates assembly language into machine code.

Simple Diagram

Source Code → Translator → Machine/Executable Code → Computer Execution

G. SOURCE CODE AND OBJECT CODE

Source Code

Source code is the original program written by a programmer using a programming language.

Example:

Number = 10

Print(number)

Object Code

Object code is the translated machine-oriented code produced from source code by a compiler or assembler.

Difference

Source Code Object Code

Written by the programmer Produced by a translator

Human-readable to varying degrees More directly usable by the computer

Written using a programming language Usually machine-oriented

Can be edited by the programmer Normally not edited like source code

H. BASIC PROGRAMMING CONCEPTS

1. Variable

A variable is a named storage location used to hold a value that may change while a program is running.

Example:

Age = 16

Here, age is a variable containing the value 16.

The value could later change.

2. Constant

A constant is a value that is intended to remain unchanged during a program’s operation.

For example, a program may use a constant to represent the value of π.

3. Data

Data refers to raw facts or values that a program processes.

Examples include:

*Names

*Numbers

*Dates

*Examination scores

*Addresses

Data Types

A data type specifies the kind of value that a variable can hold.

Common data types include:

1. Integer

Whole numbers without a decimal part.

Examples:

10, 25, 100

•

Real/Float

Numbers containing decimal values.

Examples:

3.14, 12.5, 7.25

2. Character

A single character.

Examples:

A, B, 7

•

String

A sequence of characters.

Examples:

“John”

“Computer Science”

3. Boolean

A value representing one of two logical states, commonly:

True

False

I. OPERATORS

Operators are symbols used to perform operations on data.

Arithmetic Operators

Operator Meaning

+ Addition

•

- Subtraction

* Multiplication

/ Division

% Remainder/Modulo

Example:

10 + 5 = 15

Comparison Operators

They are used to compare values.

Examples include:

Equal to (==)

Not equal to (!=)

Greater than (>)

Less than (<)

Greater than or equal to (>=)

Less than or equal to (<=)

Logical Operators

Common logical operators include:

AND

OR

NOT

J. INPUT, PROCESSING AND OUTPUT

Most computer programs involve three basic activities:

Input → Processing → Output

Input

Data supplied to a program.

Example: entering two examination scores.

Processing

The computer performs operations on the data.

Example: calculating the average score.

Output

The result produced by the program.

Example: displaying the student’s average score.

K. CONTROL STRUCTURES IN PROGRAMMING

Control structures determine the order in which instructions are executed.

The three basic structures are:

1. Sequence

Instructions are executed one after another in the order in which they appear.

Example:

Enter number

Add 10 to number

Display result

2. Selection

Selection allows a program to make a decision based on a condition.

Example:

IF score >= 50

Display “Pass”

ELSE

Display “Fail”

3. Iteration

Iteration allows a set of instructions to be repeated.

Examples include:

For loops

While loops

Example:

Repeat 5 times

Display “Hello”

L. BASIC STAGES OF PROGRAM DEVELOPMENT

Developing a program involves several stages.

•

Problem Definition

Clearly identify the problem that needs to be solved.

•

Problem Analysis

Study the problem and determine the required inputs, processes and outputs.

•

Algorithm Design

Develop a step-by-step procedure for solving the problem.

•

Coding

Translate the algorithm into a programming language.

•

Testing

Run the program to determine whether it works correctly.

•

Debugging

Identify and correct errors found during testing.

•

Documentation

Prepare explanations and records about how the program works.

•

Maintenance

Modify or improve the program when necessary after it has been deployed.

Program Development Cycle

Problem → Analysis → Algorithm → Coding → Testing → Debugging → Documentation → Maintenance

M. ERRORS IN PROGRAMMING

Errors can prevent a program from producing the expected result.

•

Syntax Error

A syntax error occurs when the rules of a programming language are not followed.

For example, incorrect spelling or punctuation in a programming statement may produce a syntax error.

•

Logical Error

A logical error occurs when the program runs but produces an incorrect result because the instructions are logically wrong.

•

Runtime Error

A runtime error occurs while a program is running.

For example, attempting an operation that the program cannot perform may cause a runtime error.

N. IMPORTANCE OF PROGRAMMING

Programming is important because it enables people to create and control digital systems.

It is used in:

•

Education – educational applications and learning platforms.

•

Banking – banking systems and transaction processing.

•

Healthcare – hospital management and medical applications.

•

Business – accounting, inventory and management systems.

•

Communication – messaging and communication applications.

•

Entertainment – games, music and video applications.

•

Transportation – ticketing and transport management systems

•

Science and Engineering – simulations, calculations and data analysis.

•

Web Development – websites and web applications.

•

Mobile Development – smartphone and tablet applications.

O. QUALITIES OF A GOOD PROGRAM

A good computer program should be:

*Correct

*Reliable

*Efficient

*Easy to understand

*Easy to maintain

*Secure

*Well documented

*User-friendly

P. DIFFERENCE BETWEEN PROGRAMMING AND CODING

Although the terms are sometimes used interchangeably:

Programming is the broader process of solving a problem, designing a solution, writing code, testing, debugging and maintaining the program.

Coding mainly refers to writing the instructions in a programming language.

Therefore, coding is an important part of programming.

SUMMARY

Programming is the process of creating instructions that enable computers to perform tasks and solve problems. A program is a set of instructions, while a programming language provides the rules and symbols used to write those instructions.

Programming languages can be broadly classified into low-level and high-level languages. Machine language and assembly language are low-level languages, while Python, Java, C++, JavaScript and other similar languages are high-level languages.

Important programming concepts include variables, constants, data types, operators, input, processing, output and control structures. Program development involves problem definition, analysis, algorithm design, coding, testing, debugging, documentation and maintenance.

03

Evaluation

OBJECTIVE QUESTIONS
What is programming?
A. Repairing computer hardware
B. Writing instructions for a computer to perform tasks
C. Installing a monitor
D. Connecting a keyboard
Which of the following is a programming language?
A. Python
B. HDMI
C. RAM
D. USB
Which programming language is considered a high-level language?
A. Machine language
B. Assembly language
C. Python
D. Binary
Machine language is mainly represented using which digits?
A. 1 and 2
B. 0 and 1
C. 2 and 3
D. 0 and 9
Which translator converts assembly language into machine code?
A. Compiler
B. Interpreter
C. Assembler
D. Browser
What is a variable?
A. A computer screen
B. A named storage location for a value
C. A type of printer
D. A network cable
Which of the following is a Boolean value?
A. 25
B. “Computer”
C. 3.14
D. True
Which control structure is used to make decisions in a program?
A. Selection
B. Storage
C. Printing
D. Formatting
Which type of error occurs when a program runs but produces an incorrect result because the logic is wrong?
A. Syntax error
B. Logical error
C. Hardware error
D. Network error
Which of the following is an important stage in program development?
A. Debugging
B. Painting
C. Typing a letter
D. Scanning a photograph
THEORY QUESTIONS
1a. Define programming, a program and a programming language.
1b. Explain the difference between low-level and high-level programming languages, giving two examples of each.
2a. What are a compiler, interpreter and assembler? State the function of each.
2b. Explain the following programming concepts: variable, constant, data type and operator.
2c. Describe the major stages involved in developing a computer program.

Prepared for SS3 learners52 reads

More DIGITAL TECHNOLOGY lessons

Week 1COMPUTER ARCHITECTURE→Week 2COMPUTER ARCHITECTURE II→Week 3ADVANCED DATA REPRESENTATION→Week 4ALGORITHMS AND PROBLEM SOLVING→