The document provides an introduction to computer programming. It discusses algorithms, pseudocode, flowcharts and several popular programming languages. It also gives examples of writing algorithms to calculate an area and determine a student's grade. The document demonstrates how to write a simple Python program to calculate an area based on width and length input. It discusses Python programming concepts like variables, identifiers, and the structure of a Python script.
2. To know basic information about computer programming
To get familiar with algorithm, pseudo-code and flowchart
To know computer programming language
BCI1103 Computer Programming (SFK)
3. Computer programs, known as software, are instructions to the computer.
Programming began in the 1940s, using memory addresses and machine code
directly.
Older programs were “monolithic,” and ran from beginning to end.
Programs are written using programming languages.
Newer programs contain modules that can be combined to form programs.
BCI1103 Computer Programming (SFK)
4. BCI1103 Computer Programming (SFK)
1101101010011010
COBOL (COmmon Business Oriented Language)
FORTRAN (FORmula TRANslation)
BASIC (Beginner All-purpose Symbolic Instructional
Code)
Pascal (named for Blaise Pascal)
Ada (named for Ada Lovelace)
C (whose developer designed B first)
Visual Basic (Basic-like visual language developed by
Microsoft)
Delphi (Pascal-like visual language developed by
Borland)
C++ (an object-oriented language, based on C)
Java (an object-oriented language)
Python
5. Algorithm, pseudo-code, flowchart
Algorithm? the list of instructions and rules that a computer needs to do to
complete a task
Algorithm pseudo-code or flowchart or both
Pseudo-code? a plain language description of the steps in an algorithm
Flowchart? a diagram that depicts a process, system or computer algorithm
BCI1103 Computer Programming (SFK)
6. Task:
Write an algorithm to calculate an area based on a given width and length. The
area is width multiply length.
BCI1103 Computer Programming (SFK)
Pseudo-code:
Input: a width and a length
1. Calculate the area by multiplying the width and
length
2. Print out the area
Output: area
Input
Process
Output
7. Task:
Write an algorithm to determine a student’s final grade and indicate whether it is
passing or failing. The final grade is calculated based on the average of four marks.
If the average mark is below than 50, the grade is FAIL and vice versa.
BCI1103 Computer Programming (SFK)
Pseudo-code:
Input: User enter Final Grade of students
1. Calculate Average
2. Check student mark if lower or higher than 50
Output: output fail or pass
8. Task:
Write an algorithm to
calculate an area based on
a given width and length.
The area is width
multiply length.
BCI1103 Computer Programming (SFK)
Flowchart
Start
Enter width,
length
Area = width x
length
Print area
End
9. Flowchart symbols that
represent certain meaning
BCI1103 Computer Programming (SFK)
10. Python Thonny (IDE)
Script to write your code
Shell to execute the written code
Variable to view your variables name and value
BCI1103 Computer Programming (SFK)
11. BCI1103 Computer Programming (SFK)
Python Script
Write code in here
Shell
Input / Output
displayed here
Variables (name,
value)/ Help/ Notes
12. Step 1: Create new file: click File New name your file
Step 2: Write code in the script
Step 3: Click File Save or “ctrl+s”
Step 4: Click Run to execute the code
BCI1103 Computer Programming (SFK)
13. The output will be displayed in the Shell
BCI1103 Computer Programming (SFK)
14. BCI1103 Computer Programming (SFK)
Pseudo-code:
Input: width, length
1. area = width * length
2. print area
Output: area
15. BCI1103 Computer Programming (SFK)
We cannot see the process on computer screen because the processes occur in
computer memory and CPU (the brain of computer).
We can see the variables name and the values that have been executed.
Program execution is ended when there is no more code after the last line.
16. BCI1103 Computer Programming (SFK)
Computer program contain codes of instructions, telling computer what to do.
The instructions are written by you as the programmer (a person writing
computer codes).
The written instructions (codes) are stored in files (computer system).
It is executed (start doing all the actions), when you open or execute the
program in computer system.
17. BCI1103 Computer Programming (SFK)
How to write scripts to solve a problem? do the step by step in flowchart and
pseudo-code
The steps must be based on the logic to solve the problem.
Logic Syntax and Semantic logic
Syntax formal rules - how valid instructions are written in a programming
language the code must be written based on valid rules in the python (eg.:
print (“ “))
Semantic set of rules that determines the instruction’s meaning in a
programming languages eg.: to calculate area, you need to have the width
and length value, you cannot write the area calculation before having the
values.
18. BCI1103 Computer Programming (SFK)
Identifiers: to name variables
Formed by combining letters, digits and underscore
Case sensitive.
2 categories:-
Standard
User-defined
19. BCI1103 Computer Programming (SFK)
Identifiers: to name variables
Formed by combining letters, digits and underscore
Case sensitive.
2 categories:-
Standard
User-defined
• print
• if
• else
• continue
• True
• False
• while
• break
………….. Python keywords already have in python that
have specific function/instruction
20. BCI1103 Computer Programming (SFK)
Identifiers: to name variables
Formed by combining letters, digits and underscore
Case sensitive.
2 categories:-
Standard
User-defined
Programmer (you) can define it.
• width
• length
• area
• firstName
• lastName
The rules:
1. Variables can be a combination of letters in lowercase (a to z) or
uppercase (A to Z) or digits (0 to 9) or an underscore _. Names like
myClass, var_1 and print_this_to_screen, all are valid example.
2. Cannot start with digit: 1var
3. Cannot use the python keywords.
4. Cannot use special symbols: ! @ # $ % ^ & * ( ).
5. Must be meaningful: first_Name, not nm;
22. BCI1103 Computer Programming (SFK)
Identifiers: to name variables
Formed by combining letters, digits and underscore
Case sensitive.
2 categories:-
Standard
User-defined
Let’s analyze the program