You are on page 1of 30

Lecture 1

 Textbook:

Python Programming: An Introduction to Computer


Science 2016, 3/ED, John Zelle

2
 Other Books:
 Wes McKinney, Python for Data Analysis: Data Wrangling with Pandas,
NumPy, and IPython, O'Reilly Media; 2nd edition (October 24, 2017)
 Python For Everyone, Horstmann, Cay S., Necaise, Rance D., Wiley; 3thEdition
2019

 Online:
https://books.goalkicker.com/PythonBook/
https://static.realpython.com/python-basics-sample-chapters.pdf

 Forums:
https://www.python.org/community/forums/
https://python-forum.io/

3
Week Topic
Week 1 Introduction to programming and program
development life cycle
Week 2 Algorithm Design Techniques
Week 3 Introduction to Python data types, input and
output variables, constant, console output and
assignment statements
Week 4 Python arithmetic operators, operators precedence
and strings
Week 5 Flow Control : Python if and nested-if Statements
Week 6 Flow Control: Python For-Loop and While-Loop
Week 7 7th Week Exam.
4
Week Topic
Week 8 Flow Control: Python Break, Python Continue,
Python Pass
Week 9 Python Functions
Week 10 Python Recursion
Week 11 Python Arrays
Week 12 12th Week Exam
Week 13 Python list, Python Set and Python files
Week 14 Data Analysis, Numpy and Scipy libraries
Week 15 Python Advanced Problems Solving
Week 16 Final Exam.
5
Week Exam / Quiz
Week 6 - lab Quiz (5 marks)
Week 7 – lecture Exam (25 marks)
Week 12 - lecture Exam (20 marks)
Week 12 – lab Practical Quiz (5 marks)
Sheets Submitting sheets in time & activity work (5 marks)
Week 16 Final Exam (40 marks)

6
 Introduction
 Types of ProgrammingLanguages
 Program Development Life Cycle

7
 Computers can carry out a wide range of tasks because
they execute different programs, each of which directs
the computer to work on a specific task.
 The computer itself is a machine that stores data
(numbers, words, pictures), interacts with devices (the
monitor, the sound system, the printer), and executes
programs.
 A computer program tells a computer, in minute detail,
the sequence of steps that are needed to fulfill a task.
 The physical computer and peripheral devices are
collectively called the hardware.
 The programs the computer executes are called the
software.

8
9
 Programmers write instructions in various
programming languages, some directly understandable
by computers and others requiring intermediate
translation steps.
 Hundreds of such languages are in use today. These

may be divided into three general types:


◦ Machine languages
◦ Assembly languages
◦ High-level languages

10
 Machine language is directly executed by the computer.
It is generally consist of strings of numbers (1s & 0s)
that instruct computers to perform their most
elementary operations one at a time.
 It is machine dependent (a particular machine language

can be used only one type of computer).

11
 Assembly languages use English-like abbreviations to
represent elementary operations. Can not be
understand directly by computers.
 Translator programs called assemblers were developed

to convert early assembly-language programs to


machine language.

12
 High-level languages were developed to speed the
programming process, in which single statements
could be written to accomplish substantial tasks.
 Translator programs called compilers convert high-

level language programs into machine language.


 High-level languages allow writing instructions that

look like everyday English & contain mathematical


notations.

grossPay = basePay + overTimePay

13
• is the process associated with creating successful
applications programs. It include these phases:
1. Analysis: determine inputs, outputs, how to process inputs to
derive the outputs, additional requirements, inputs constraints

2. Design: write down solution architecture in terms of flow
charts or pseudo-code
3. Development: implementation / programming phase
4. Testing: to assess the program to handle any errors; syntax,
logical or run-time errors
5. Maintenance: update; applying new requirements to existing
program

14
15
 During problem analysis, a systems analyst and
programmer review specifications and talk with
users to fully understand what the software
should do.
 Documentation consists of:

 Program specifications,
 Timetable,
 Which language will be used,
 How the program will be tested,
 What documentation is required.

16
Program design tools are planning tools:

A. Program flowchart: uses geometric symbols and familiar


relational operators to provide a graphic display of the
sequence of steps involved in a program.

B. Pseudocode: uses English-like statements in place of the


graphic symbols of the flowchart.

17
2- Program Design:
A. Program flowchart
‒ uses geometric symbols &
familiar relational operators to
provide graphic display of the
sequence of steps involved in a
program.

‒ The steps in a flowchart follow each


other in the same logical sequence
as their corresponding program
statements will follow in a program.

A series of actions are performed in sequence after each other

18
 Draw a flowchart that asks the user to enter the
length of the square side and then calculate the
area ?
Start

read the
side length

Area=Length2

Stop

19
2- Program Design:
B. Pseudocode
‒ uses English-like statements in place of the
graphic symbols of the flowchart.
‒ Unlike a flowchart, pseudocode is easy to modify
and can be embedded into a program as comments.
‒ No standard set of rules exists for writing
pseudocode, although a number of conventions have
been developed.

20
Write a pseudocode algorithm that computes the area of a circle ?

Problem: Calculate and display the area of the circle


Discussion: Uses mathematical knowledge, that is area = r2

Output: area of the circle


Input: radius of the circle
Processing: Find the area of the circle;
area = 3.14 * radius * radius

Pseudocode algorithm
input radius
set area to 3.14 * radius * radius
output area

21
 Coding: actual process of creating the program in a
programming language.
 Programming language must be chosen.
 Coding standards should be adhered to.
 Make use of reusable code and data dictionaries.
 Translate coded programs into executable code.

22
3- Program Coding - Translators
• The coded program is referred to as source code.
to be executed, the program is converted by the
computer to object code using a special program.
• A compiler translates the entire program into machine
language before executing it. The program then doesn’t need
to be recompiled until it is modified.
• An interpreter translates program statements one at a time.
Interpreters are helpful during the debugging stage, but are
slower during execution of the finished program.
• An assembler converts assembly-language statements into
machine language.

23
3- Program Coding - Translators

24
 Debugging: process of making sure a program is free of
errors or bugs.
 Preliminary debugging begins after the program has been
entered into the computer system. Two common types of
errors are syntax errors and logic errors.
 Types of errors are:
– A syntax error: occurs when the programmer has not followed
the syntax rules of the language.
– A logic error, or execution-time error: results when the
command syntax is correct but the program is producing
incorrect results due to incorrect equation or design.
– A run time error: occurs at running time of a program as e.g.
dividing by zero or access not found file.

25
4- Program Debugging and Testing

– A syntax error: occurs when the programmer has not followed


the syntax rules of the language.

26
4- Program Debugging and Testing

– A logic error: or execution-time error: results when the


command syntax is correct but the program is producing
incorrect results due to incorrect equation or design.

27
4- Program Debugging and Testing

– A run time error: occurs at running time of a program as e.g.


dividing by zero or access not found file.

28
 Program maintenance: process of updating
software so that it continues to be useful.
 A costly process, but can be used to extend the life of a
program.

 Documentation consists of amended program package


reflecting what problems occurred and what program
changes were made.

29

You might also like