Lecture 1
Lecture 1
Lecture 1
Python Programming
Lecturer Mahazani Mohamad
Office Level 2, Engineering Summit
(Electrical Engineering Block)
Phone 03 7967 5246
E-mail [email protected]
References:
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 2021/2022
Course Outcomes
At the end of the course, students are able to:
1 Introduction to Python
2 Input, Output, Variables and Data Type
3 Operators and Expressions
4 Arithmetic Operations
5 Bitwise Operations and Complex Numbers
6 Logical Operators and Control Loops Test (20%)
7 Sequences, Strings and Sets
8 Recursions and iterations
9 Functions and Modules
10 Class
11 Class Inheritance
12 PyQt, Windows, GUI, Slots and Buddies
13 Presentation of Group Assignment Assignment (20%)
14 Revision Week
E1 Exam Week 1 Final (60%)
E2 Exam Week 2
3
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
Macintosh.
• 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 it.
• Python is a programming language that also
supports scripting, making it suitable for rapid
application development.
Python Implementations
• The traditional Python implementation is called
CPython
• There are many alternative implementations
based on CPython 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
applications.
Interacting with Python
• There are two ways to work with Python
interactively:
– 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
modules.
IDE (Integrated Development Environment)