Lecture 01
Lecture 01
Lecture 01
Lecture 01-Introduction
Outline
• What is a computer?
• What is computer programming?
• Programming Languages
• Software Development Method
• Pseudo Code & Flowchart
• Python Programming Language
• Why Python?
2
What is a computer?
• A computer is a multipurpose electronic device that accepts data as input,
processes it according to a series of instructions (called computer programs
or software), and produces information as output.
4
5
Software
• A set of instructions that makes the computer perform tasks (also
called computer program)
• Two categories of software
▪ System software is to help computer carry out its basic operating
functions and manage its own resources such as operating systems
(Windows, Linux, Unix, etc), network management systems, and
device drivers (for printer, scanner, etc).
▪ Application software is used to help people carry out tasks such as
creating documents (MS-Word), tracking finances (Banking Systems),
editing photos (Photoshop), and Student Information System (SIS) at
UHB.
6
Data
• Individual facts or information, e.g., cell phone
number, date of birth of a person, etc.
• Computer reads and stores data of all kinds
(words, numbers, images, or sound) in digital
form: sequence of bits
• Bit:
▪ The smallest data item in a computer
▪ Can have the value 0 or 1
7
What is computer programming?
8
Programming Languages
• Machine Language – A collection of binary numbers
▪ Not standardized, i.e., There is a different machine language for every
processor family.
• Assembly Language - mnemonic codes that corresponds to
machine language instructions.
▪ Low level: Very close to the actual machine language.
• High-level Languages - Combine algebraic expressions and
symbols from English
▪ High Level : Very far away from the actual machine language
▪ Source code: A program written in a high-level language
▪ For example: Python, Java, C, C++, C#, Perl, Fortran, Cobol.
9
Programming Languages
Output Text to Screen
1001 011100 10001111001110011110110011101100100110
Machine
OUTPUT MONITOR Hello World! Language
Assembly
Language
print(‘Hello World!’)
Python
Language
11
Compiler vs. Interpreter
12
Software Development Method
1. Specify problem requirements
2. Analyze the problem
3. Design the algorithm to solve the problem
4. Implement the algorithm
5. Test and verify the completed program
6. Maintain and update the program
13
Steps Defined
1. Problem Specification - Specifying the problem requirements
forces you to understand the problem more clearly.
2. Analysis - Analyzing the problem involves identifying the
problem’s inputs, outputs, and additional requirements.
3. Design - Designing the algorithm to solve the problem
requires you to develop a list of steps called an algorithm that
solves the problem and then to verify the steps.
4. Implementation - writing the algorithm as a program.
5. Testing - verifying that the program actually works as desired.
6. Maintenance - finding previously undetected errors and keep
14
it up-to-date.
Example:
Converting Miles to Kilometers
1. Problem
▪ To convert a list of miles to kilometers. You
decide to write a program to do this job.
2. Analysis
▪ We need to get miles as input
▪ We know 1 mile = 1.609 kilometers
▪ We need to output kilometers
3. Design
1. Get distance in miles
2. Convert to kilometers
3. Display kilometers
15
Miles to Kilometers (contd.)
5. Test
▪ We need to test the previous program to make
sure it works. To test we run our program and
enter different values and make sure the output is
correct.
6. Maintenance
▪ You may want to convert to other units of
distance later.
16
Pseudo Code & Flowchart
• Algorithm - A list of steps for solving a problem.
▪ Algorithms can be expressed either in Pseudo code or in
Flowchart
• Pseudo code - A combination of English phrases and
language constructs to describe algorithm steps
• Flowchart - A diagram that shows the step-by-step
execution of a program.
17
Why use pseudo code?
• Pseudo code cannot be compiled or executed, and there are no
real formatting or syntax rules.
• It is simply one step - an important one - in producing the final
code.
• The benefit of pseudo code is that it enables the programmer to
concentrate on the algorithms without worrying about all the
syntactic details of a particular programming language.
• In fact, you can write pseudo code without even knowing what
programming language you will use for the final implementation.
• Example:
Input Miles
Kilometers = Miles * 1.609
Output Kilometers 18
Flowcharts
Flowchart uses boxes and arrows to show step by step
execution of a program.
Process Start or Terminal
Decision Document
Start
End
20
Control structures in Flowcharts
Statemement a T F F
Condition p? Condition p?
T
Statemement b
Statemement a Statemement b Statemement block
Statemement c
21
Example of a Program Flowchart
Example 1
Draw a flowchart to
compute the perimeter of a
rectangle (input height and
base).
22
Python
• An object-oriented scripting language released publicly
in 1991.
• Developed by Guido van Rossum of the National
Research Institute for Mathematics and Computer
Science in Amsterdam.
• Rapidly become one of the world’s most popular
programming languages.
• particularly popular for educational and scientific
computing.
23
Why Python?
• It’s No. 1 programming language for Data Science
Applications!
• It’s open source, free and widely available with a
massive open-source community.
• It’s easier to learn.
• It’s simple to use.
• There are massive numbers of free open-source
Python libraries.
24
25