2. COURSE OUTLINE
PART I: PROGRAMMING PRINCIPLE
• CHAPTER 1: PROGRAMMING CONCEPTS
• CHAPTER 2: PROGRAMMING STYLES
PART II: PROGRAMMING TECHNIQUES IN PYTHON
• CHAPTER 1: PROGRAMMING ENVIRONMENT
• Variables, Data Types, Statements, Assignment etc.
• CHAPTER 2: CONTROL STRUCTURE IN PYTHON
• CHAPTER 3: ARRAY & LIST PROGRAMMING IN PYTHON
• CHAPTER 4: MODULAR PROGRAMMING IN PYTHON
2
3. CHAPTER ONE: PROGRAMMING CONCEPTS
1.1 Programming
1.2 Programming Languages
1.3 Programming Paradigms
1.4 Programming Languages Application Domains
1.5 Programming Languages and their Inventors
1.6 Prerequisite to Programming
3
4. 1.1 Programming & Programming Languages
• Programming can be viewed as an act of coding solution for a problem.
• It can also be defined as an act of giving instruction to the computer to
carry out a task.
• It simply implies the ability of a programmer to communicate with the
computer system in a particular programming language.
• It is a transformational act that brings about changes in the status of task –
e.g. manual task to computational one.
4
What is Programming?
5. - Related Concepts to Programming
• PROGRAM: This implies the written instruction, which
the computer takes in and act upon. It has the synonyms
CODE.
• PROGRAMMER: This is a person that indulges in coding
for solutions. He is regarded as an expert in writing
computer codes. His major responsible is to write
programs that performs a given or specified function.
5
6. Programming Languages
•These indicate the language of choice
for which the programmer
communicates with the computer
machine.
•In other words, programming language
refers to the language with which a
programmer codes.
6
7. Programming Languages - Types
•We have 3 types:
• Machine Language
• Low-Level Language
• High Level Language
7
8. Programming Languages – Types cont’d
•Machine Language (ML)
• This refers to the language which the
computer understands. It is a language in
which all codes/instructions are
represented in the form of 0s and 1s.
8
9. Programming Languages – Types cont’d
•Low-Level Language (LLL)
•This language is very much close to
machine language. It needs little
translator to real machine language. It is
regarded as SYMBOLIC Language. A good
and common example is the ASSEMBLY
Language.
9
10. Programming Languages – Types cont’d
•High-Level Language (HLL)
• This is a language that is close to normal
human English Language. It isn’t a languages
the computer understands, rather it needs the
help of an interpreter or a compiler before
computer could understand it. Examples here
includes QBasic (Quick – Beginners’ All Purpose
Symbolic and Instruction Code), Fortran
(FORmulaTRANslator), Pascal (Delphi), Java, C,
C++, C#, Python, Ada, Eiffel, PHP (Hypertext
10
11. Programming Paradigms
• Programming Paradigms imply trend & evolution
of programming languages.
• Early Program Development => Machine Language
• 1st Program Developed => Assembly Language
• Real Program Developed => Fortran (1954) John Backus &
IBM Team.
• Subsequent Breakthru => Algol60 (1960)
11
12. Programming Paradigms Cont’d…
• IMPERATIVE PROGRAMMING
This is the type of programming that deals with
scientific computation i.e. Its found useful in
handling mathematical computation. In this
programming language, assignment, sequence and
control statement are very important.
Examples of this programming paradigm are:
FORTRAN, COBOL ,C / C++ and PASCAL
12
13. Programming Paradigms Cont’d…
• OBJECT ORIENTED PROGRAMMING (OOP)
• This is a type of programming in which object
interact by sending messages that change their
state. In this programming type, inheritance,
polymorphism and object modeling are essential
element.
• Examples of programming languages in this
paradigm include: C++, JAVA, SMALLTALK, EIFFEL,
PHP & VISUAL BASIC.NET
13
14. Programming Paradigms Cont’d…
• FUNCTIONAL PROGRAMMING
• This programming paradigms deals with
mathematical functions in which the domain
serves as the input and the range serves as the
output.
• Example of this programming paradigm includes:
LISP, SCHEME, HASKEL, MIRANDA, MAPLE,
MATHEMATICA and MATLAB.
14
15. Programming Paradigms Cont’d…
• LOGIC / DECLARATIVE PROGRAMMING
• This programming paradigms deal with collection
of logical declaration about what outcome a
function should accomplish.
• Example of this paradigm includes: PROLOG,
SEQUEL, SQL and RPG
15
16. Programming Paradigms Cont’d…
• EVENT-DRIVEN PROGRAMMING
• This programming paradigms deals with design of
program that respond to unpredictable events.
• This event are normally generated from users’
actions e.g. mouse click, key press.
• Example of this paradigm includes: VISUAL BASIC,
VISUAL BASIC.NET, VISUAL C++, VISUAL C#, & JAVA
16
17. Programming Paradigms Cont’d…
• CONCURRENT PROGRAMMING
• This programming paradigm deals with collection
of cooperating process by sharing resources
(information) but operating asynchronously.
• Example of programming languages in this group
include: LINDA, CONCURRENT PASCAL (DELPHI),
HIGH PERFORMANCE FORTRAN and JAVA
17
18. Programming Language Application Domains
• These include:
i. Scientific Programming (SP)
ii. Management information system (MIS)
iii. Artificial Intelligence (AI)
iv. System Programming (SP)
v. Web-centric Programming (WP)
18
19. Programming Language Application Domains…
• SCIENTIFIC PROGRAMMING: This is programming
language that is used for handling complex
computations. They are also very useful for
teaching and learning. Example of this
programming language includes: FORTRAN,
COBOL, PASCAL, C and BASIC
• NOTE: Scientific programming falls under
imperative programming paradigm
19
20. Programming Language Application Domains…
• MANAGEMENT INFORMATION SYSTEM: This are
program that are used for handling organization
information system e.g. payroll system,
accounting system, inventory system, online sale
and marketing system. Example of this
programming language includes: SQL, COBOL and
RPG.
• NOTE: MIS falls under logic / declarative
programming paradigm
20
21. Programming Language Application Domains…
• ARTIFICIAL INTELLIGENCE: This are programming
types that are used to develop software that
model after human intelligent behavior e.g.
robot. Example of this programming language
includes: LISP, PROLOG, MATLAB and SCHEME.
• NOTE: AI falls under programming language
paradigm of functional and logic programming
language.
21
22. Programming Language Application Domains…
• SYSTEM PROGRAMMING: This is a programming type
which assist in the design and development of software
on which other software runs i.e. system programming
deals with developing software that act as platform on
which other programs runs.
• Examples are OS SOFTWARE, NETWORK SOFTWARE,
INTERPRETER AND COMPILER. A Common example of
programming language use is C.
• NOTE: SP falls under imperative programming language
paradigm.
22
23. Programming Language Application Domains…
• WEB-CENTRIC: This programming type involves
developing programs that run on the internet.
Web-centric programming is like a two-edged
sword, as it derives from both OOP and Event-
driven programming paradigm.
• Programming languages used include: JAVA,
VISUAL BASIC, VISUAL BASIC.NET, PHP, HTML,
JAVASCRIPT and C++ etc.
• Web-Centric falls under OOP and Event-Driven
Paradigms
23
24. PROGRAMMING LANGUAGES AND THEIR INVENTORS 24
ADA: It was invented in 1982 by CHARLES BABBAGE but was
named after a woman called ADA
ALGOL: (Algorithmitic language) It was design by a committee
in 1960.
APL: (A programming language) It was design to handle matrix
calculation and the designer is named KENNETH IVERSON in
the early 1960s.
LISP: (List processing) it was invented in 1960 by JOHN
McCARTHY
25. TAKE HOME I
• Discuss the following programming languages, stating
their full names (where applicable), date
invented/developed and also the inventor/developer.
• Java
• C
• C++
• C#
• PHP
25
26. PRE-REQUISITE TO PROGRAMMING 26
PSEUDOCODE
•Pseudocode does the same function as
Algorithm but the language of expression
differs. While in algorithm, more technical
terms are used, raw English-like statements
are used in Pseudocode. While algorithm
expressions are formal that of Pseudocode
sounds informal.
27. PRE-REQUISITE TO PROGRAMMING 27
PSEUDOCODE - ILLUSTRATION
• Literally, take for instance if you are hungry and
intend ‘executing’ a rice – what are the psudocode
steps/procedures for ensuring this? (varied
depending on how u want to program to flow and
be implemented).
• Design a pseudocode that solves the need to
compute for the scores of ten (10) students in
CSC101, MAT101 and PHY101, computing their
average scores.
28. PRE-REQUISITE TO PROGRAMMING 28
SOLUTION I
• Clean up / Prepare the utensils for the cooking
• Lit the stove/cooker
• Put water in the pot and place on the cooker
• Wash the rice in a basin and put unto the water-pot
• Depending on the type of rice been cooked, put salt or
any other ingredient.
• Cook to taste
• When done, Stop/End Cooking
29. PRE-REQUISITE TO PROGRAMMING 29
SOLUTION II
• Get the scores in the 3courses
• Carry out their calculations – their sum
• From there, compute their average
• Continue this steps until there is no more student to input
for
• Output the result
• Stop the process
30. PRE-REQUISITE TO PROGRAMMING 30
ALGORITHM
• Algorithms are sequence of steps taken in solving
a problem. It involves highlighting intended
action(s) for executing a task.
• In programming context, an algorithm can be
described as a guide to logical coding that yields
the intended implementation.
31. PRE-REQUISITE TO PROGRAMMING 31
PSEUDOCODE - ILLUSTRATION
• Literally, take for instance if you are hungry and
intend ‘executing’ a rice – what are the
algorithmic steps/procedures for ensuring this?
(varied depending on how u want to program to
flow and be implemented).
• Design an algorithm that solves the need to
compute for the scores of ten (10) students in
CSC101, MAT101 and PHY101, computing their
average scores.
32. PRE-REQUISITE TO PROGRAMMING 32
SOLUTION I
• Set utensils = Available
• Set stove/cooker ON
• Cooker = Water-Pot + Water
• Water-Pot = Rice
• If Rice requires Salt, Then Insert
• Else Put/Insert other Ingredients
• Set Cooking = Max Level/Time
• If Cooking = ‘DONE’ Then STOP/END Cooking
• Else CONTINUE Cooking
33. PRE-REQUISITE TO PROGRAMMING 33
SOLUTION II
• Enter/Input Value for CSC101, MAT101 and PHY101 scores
• Set Sum = CSC101 + MAT101 + PHY101
• Set Average = Sum/3
• Loop Until Student>10
• Output to the screen
• Stop
34. Converting Pseudocode/Algorithm to Program Solution 34
SOLUTION II – using QBasic
5 CLS
10 REM
12 LET N = 0
15 INPUT “Enter Value for CSC101”, csc
20 INPUT “Enter Value for MAT101”, mat
25 INPUT “Enter Value for PHY101”, phy
30 LET SUM = csc+mat+phy
35 LET AVG = SUM/3
40 PRINT “The sum of the 3courses is: ” SUM
45 PRINT “The average of the 3courses is: ” AVG
46 N = N + 1
47 IF N<=10 GOTO 15
50 END
35. TAKE HOME II 35
(1) Write a Pseudocode and Algorithm to solve:
x2 + y3 – (z * w/2)
(2) Write a Pseudocode and Algorithm to compute a candidate’s age
given the birthyear and specifying the current year.
(3) Write a Pseudocode and Algorithm to accepts the UTME and
PUTME scores of candidates, screen out and compute as appropriate
where:
(i) UTME must be >=180
(ii) PUTME must be >=40
(4) Convert 1, 2 and 3 to programming solution using QBasic.