APPLICATION LABORATORY II
Sherina Sally
Introduction to Python Department of ICT
Faculty of Technology,
University of Colombo
ASSESSMENT CRITERIA
Continuous Assessment: 40%
End Examination: 60%
All Rights Reserved
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 2
1
REFERENCES
How to think like a computer scientist: learning with Python / Allen Downey, Je®rey Elkner, Chris Meyers. ISBN 0-
9716775-0-6
Guttag, John. Introduction to Computation and Programming Using Python: With Application to Understanding
Data. MIT Press, 2016. ISBN: 9780262529624
All Rights Reserved
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 3
OUTLINE
• History of Python
• Characteristics of Python
All Rights Reserved
• Flavors of Python
• Versions of Python
• Installing Python
• Working with Python
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 4
2
INTRODUCTION TO PYTHON
• High-level language
• A general purpose language
All Rights Reserved
• Emphasizes on code readability and increase productivity
• Fewer code lines to write a program compared to languages as C, C++, Java, C#
• Free and Opensource
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 5
HISTORY OF PYTHON
• Created by Guido van Rossum in late 1980’s
• Implementation started as a leisure project at Centrum Wiskunde & Informatica (CWI)
• The first release was in 1991
All Rights Reserved
• A successor of the language ABC
• The name ‘Python’ was based on a favorite TV series of Guido
• Adopted the good features from ABC and introduced solutions to the flaws Guido van Rossum
The Story of Python, by Its Creator, Guido van Rossum
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 6
3
CHARACTERISTICS OF PYTHON
• Platform independent
• Portable
• Procedural and object oriented
All Rights Reserved
• Dynamically typed: Data types are assigned to variables based on the value
• Interpreted: compilation doesn’t happen explicitly
• Embedded: Can include in other programming languages
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 7
FLAVORS OF PYTHON
Types of compilers which integrates other programming languages into Python
Cpython Implemented in C
Jpython Python programs can be run on the Java platform
All Rights Reserved
PyPy A faster compiler implemented using the Python language
IronPython Compiler for the .NET platform. Implemented in C#
Anaconda Python Handles large scale of data processing
Ruby Python Embeds Python interpreter in Ruby application
Pythonxy Includes scientific and engineering related packages
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 8
4
VERSIONS OF PYTHON
Source: https://en.wikipedia.org/wiki/History_of_Python
0.9 1.2
1991 1995
1.0 1.1 2.0
All Rights Reserved
1994 1994 2000
3.1
2.1 3.9
3.0 2009
2001 2020
2.7 2008
2.2 3.10
2010
2001 2021
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 9
WHEN TO USE PYTHON?
Web
Development
Data Science
Engineering Applications
Applications
All Rights Reserved
Python
Business
Applications Scripting
Desktop
GUI
Applications
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 10
5
INSTALLING PYTHON
• Windows/ Linux/ Mac OS : Download and Install Python to a PC
• Online Compiler: Online Python Compiler
All Rights Reserved
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 11
PYTHON SHELL
Execute python commands Execute Python scripts
All Rights Reserved
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 12
6
INTERACTIVE AND SCRIPT MODE
• Interactive mode
• Provides a quick method to execute code lines
• Preferred for short programs which expects faster results
All Rights Reserved
• Recommended for learning activities
• Script Mode
• Executes code written in a python file
• Modifying code is possible
• A separate file is created
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 13
WORKING WITH THE INTERACTIVE SHELL
Command Description
C:\Users> python Starts the python shell
C:\Users> python --version
or Displays the Python version installed in the computer
All Rights Reserved
C:\Users> python -V
C:\Users> python test.py Executes the test.py script and displays the result
>>> quit()
or Exits from the Python shell and returns to the windows console
>>> Ctrl-Z
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 14
7
IDE AND CODE EDITORS
• Provides syntax highlighting, code auto completion
• Code editors are light weighted than an IDE
All Rights Reserved
• IDEs consists of additional features used for development
Department of ICT, Faculty of Technology, University of Colombo All Rights Reserved 15
Department of ICT, Faculty of Technology, University of Colombo