Sei sulla pagina 1di 13

KIX 3004

Python Programming
Lecturer Mahazani Mohamad
Office Level 2, Engineering Summit
(Electrical Engineering Block)
Phone 03 7967 5246

1. B.M Harwani, “Introduction to Python Programming”, Cengage
Learning, Boston, 2012.
2. William F. Punch, Richard Enbody, “The Practice of Computing
Using Python, Global Edition”, Pearson, 3rd Edition, 2017.
Semester 1, Session 2018/2019
Course Outcomes
At the end of the course, students are able to:

1. To describe the basic building blocks of a phyton and

able to describe the importance of Python
2. To develop algorithm and computer code according to
3. To identity syntax errors and program errors and rectify
the codes
4. To apply object-oriented programming to develop
window GUI
Wee Topics Assessments
1 Introduction to Python
2 Input, output, variables, data type, operators, and expressions
3 Arithmetic operations, logical operators and loops Tests (20%)
4 Bitwise operations and complex numbers Assignment 1
5 Sequences, strings and sets Final Q1 (15%)
Final Q2 (15%)
6 Recursions and iterations
7 Functions and modules
8 Class, inheritance, overloading and descriptors
Final Q3(15%)
9 File handling
10 PyQt, windows, GUI, slots and buddies
11 Widgets, buttons, checkboxes, scrollbars and sliders
Assignment 2
12 Box, tables, webpages and graphics (10%)
Final Q4 (15%)
13 Menus and toolbars
14 Layout and database
Introduction to Python
• Python is a very powerful high-level, dynamic
object-oriented programming language created
by Guido van Rossum in 1991.
• It is implemented in C, and relies on the
extensive portable C libraries.
• It is a cross-platform language and runs on all
major hardware platforms and operating
systems, including Windows, Linux/UNIX, and
• Python has an easy-to-use syntax and is quite
easy to learn, making it suitable for those who
are still learning to program.
• Python has a rich set of supporting libraries,
and many third-party modules are available for
• Python is a programming language that also
supports scripting, making it suitable for rapid
application development.
Python Implementations
• The traditional Python implementation is called
• There are many alternative implementations
based on CPyhton such as, Jython, Iron-Python,
PyPy ,Stackless Python and MicroPython
• Other parties have re-packaged CPython where
these re-packagings often include more libraries
or are specialized for a particular application
– Anaconda Python (the one that we are going to use)
Features of Python
• Python is easy to learn.
– Programmers familiar with traditional languages will find all the familiar
constructs, such as loops, conditional statements, arrays, and so on.
• It has easier to read syntax.
– It avoids the use of punctuation characters like { } $ / and \.
• It uses white space to indent lines for defining blocks instead of
using brackets.
• Python is free.
– You can download and install any version of Python and use it to develop
software for commercial or personal applications without paying a penny.
Python is developed under the open-source model. You can copy Python,
modify it, and even resell it.
• It comes with a large number of libraries included
– there are many more that you can download and install.
• Python can be integrated with other languages, like C,
C++, and Java.
• Python is an interpreted language
– Therefore it supports a complete debugging and diagnostic
environment making the job of fixing mistakes much faster.
• Python is a good choice for web development,
networking, games, data processing, and business
Interacting with Python
• There are two ways to work with Python
– Using Command Line Mode
– Using IDE
Command Line Mode
• In command line mode, you type Python
instructions one line at a time.
• You can also import code from other files or
IDE (Integrated Development Environment)

• We are going to use Spyder as the IDE from

Anaconda python
Writing Your First Python Program

# The program calculates area of rectangle

print ("Area of rectangle is ", a)

• Save it to your computer in any desired folder

by any name, for example,
• The program consists of two variables, l and
b, initialized to values 8 and 5, respectively.
• The l and b variables here represent the
length and breadth of a rectangle.
• The l and b are multiplied, and the result is
stored in a third variable, a, that is then
displayed as the area of a rectangle.