Introduction to Python
Sensitivity: Internal & Restricted
Agenda
1 Introduction to Scripting 5 Getting started with Python
2 What is Python? 6 Python Interpreter
3 Features of Python 7 Introduction to Anaconda distribution
4 History of Python
Sensitivity: Internal & Restricted © confidential 2
Introduction to Scripting
Sensitivity: Internal & Restricted
Introduction to Scripting
• A scripting or script language is a programming language for a special run-time
environment that automates the execution of tasks.
• They do not require the compilation step and are rather interpreted.
• Environments that can be automated through scripting include software applications, web
pages within a web browser, usage of the shells of operating systems (OS), embedded
systems, as well as numerous games.
• The term scripting language is also used loosely to refer to dynamic high-level general-
purpose languages, such as Perl, PowerShell, Python, and Tcl.
• The term script often used for small programs (up to a few thousand lines of code) in such
languages.
Sensitivity: Internal & Restricted © confidential 4
Introduction to Scripting
• Typical scripting languages are intended to be very fast to learn and write in.
• Typically a script is executed from start to finish with no explicit entry point.
Printing Hello World in Java: In Python:
public class Sample { print("Hello World")
public static void main(String args[])
{
System.out.println("Hello World");
In Perl:
}
} print "Hello World";
Sensitivity: Internal & Restricted © confidential 5
What is Python?
Sensitivity: Internal & Restricted
What is Python?
• Python is a high level and interpreted programming language.
• Python is beginner friendly and multi-purpose language.
• It supports Object-Oriented style of programming.
• It is the world’s fastest growing and a popular programming language.
• It is used by Software Engineers, Mathematicians, Data Analysts, Scientists, Accountants,
Network Engineers etc..
• It is used in various areas like Data analysis and Visualization, Artificial Intelligence and
Machine Learning, Automation, building Web/Mobile/Desktop applications, Software
Testing and Hacking etc..
Sensitivity: Internal & Restricted © confidential 7
Why do we need Python?
• Solve complex problems in less time with fewer lines of code.
• We can build and run Python applications in Windows, Mac and Linux OS.
• Python has huge community support https://www.python.org/community/
• Python has a large ecosystem of libraries, frameworks and tools.
• It is free and an open source language.
Sensitivity: Internal & Restricted © confidential 8
Features of Python
Sensitivity: Internal & Restricted
Features of Python
Easy to learn Object-Oriented language
Readability Large standard library
Interpreted language GUI programming support
Cross-platform language Database support
Free and Open Source Easy integration with other languages like
C, C++, Java.
Sensitivity: Internal & Restricted © confidential 10
History of Python
Sensitivity: Internal & Restricted
History of Python
• The idea of Python formed in late 1980s and It’s implementation was started in December
1989 by Guido van Rossum.
• Python reached version 1.0 in January 1994 and version 2.0 released on October 2000.
• Python 3.0 (also called "Python 3000" or "Py3K") was released on December 3, 2008.
• This broke backward compatibility, and much Python 2 code does not run unmodified on
Python 3.
• Python 3.8.1 is the latest version, released on December 18, 2019.
• Since 2003, Python has consistently ranked in the top ten most popular programming
languages, as of December 2018 it is the third most popular language.
Sensitivity: Internal & Restricted © confidential 12
Getting started with Python
Sensitivity: Internal & Restricted
Getting started with Python
• Download the latest version of Python from: https://www.python.org/downloads/windows/
• Make sure you are downloading the executable file for the correct version of your
windows(32 or 64 bit).
• Double click and run the exe file.
• Check Install launcher for all users (recommended) and Add Python 3.8 to PATH options.
• Make a note of the installation directory path and select Install Now.
Sensitivity: Internal & Restricted © confidential 14
Getting started with Python
Sensitivity: Internal & Restricted © confidential 15
Getting started with Python
Sensitivity: Internal & Restricted © confidential 16
Getting started with Python
Sensitivity: Internal & Restricted © confidential 17
Getting started with Python
Python is installed in the previously noted path:
Sensitivity: Internal & Restricted © confidential 18
Getting started with Python
The same path has been added to the Path Environment Variable:
• Right click on This PC Properties Advanced System Properties Environment
Variables.
• Under User Variables, select Path and click Edit to view the above details.
Sensitivity: Internal & Restricted © confidential 19
Getting started with Python
• Open command prompt and run this command python
• Python interactive mode is available now, which gives immediate feedback for each
statement. Type 2*4 and hit enter.
Sensitivity: Internal & Restricted © confidential 20
Getting started with Python
Printing Hello World in Interactive mode:
Script file:
• We cannot write the code every-time on the interactive terminal.
• We can write our code in a file which can be executed later.
• For this purpose, open an editor like notepad, write the following code in it.
Sensitivity: Internal & Restricted © confidential 21
Getting started with Python
• File Save as Change Save as type to All Files
• File name should be suffixed with .py
Sensitivity: Internal & Restricted © confidential 22
Getting started with Python
• Save the file. Our script file is ready.
• Open command prompt and navigate to the location where our script file is located.
Sensitivity: Internal & Restricted © confidential 23
Getting started with Python
• Run the script file with this command: python FileName.py
Sensitivity: Internal & Restricted © confidential 24
Python Interpreter
Sensitivity: Internal & Restricted
Python Interpreter
Let us understand the runtime structure of Python
When Python runs your script, there are a few steps that Python carries out before you see
the output:
1. Source code is translated to bytecode.
2. Then it is routed to Python Virtual Machine (PVM) which interprets it into machine code.
Source code: .py file containing human readable format of python statements.
Bytecode: Low-level platform-independent representation of source code.
Machine code: 0s and 1s which a computer can understand.
Sensitivity: Internal & Restricted © confidential 26
Python Interpreter
• In Python 3.x the .pyc files are saved in a __pycache__ directory.
Library
modules
Interpreter
Source
Bytecode Machine
code Compiler PVM
code
.pyc file
.py file
Sensitivity: Internal & Restricted © confidential 27
Introduction to Anaconda
distribution
Sensitivity: Internal & Restricted
Introduction to Anaconda distribution
• Anaconda is a free and open-source distribution of the Python and R programming
languages for scientific computing (data science, machine learning applications, predictive
analytics, etc.)
• It aims to simplify package management and deployment.
• Anaconda distribution comes with more than 1,500 packages.
• The default installation of Anaconda3 includes Python 3.7
• It also includes a GUI, Anaconda Navigator.
• Anaconda Navigator is a desktop graphical user interface (GUI) included in Anaconda
distribution that allows users to launch applications and manage packages and
environments without using command-line commands.
Sensitivity: Internal & Restricted © confidential 29
Introduction to Anaconda distribution
The following applications are available by default in Navigator:
• JupyterLab
• Jupyter Notebook
• QtConsole
• Spyder
• Glue
• Orange
• RStudio
• Visual Studio Code
Sensitivity: Internal & Restricted © confidential 30
Introduction to Anaconda distribution
• Download Anaconda3 for Windows from: https://www.anaconda.com/distribution/
Sensitivity: Internal & Restricted © confidential 31
Introduction to Anaconda distribution
• Double click and run the exe file.
• Accept the license agreement and proceed.
• Choose Install for Just Me (recommended) option.
Sensitivity: Internal & Restricted © confidential 32
Introduction to Anaconda distribution
Sensitivity: Internal & Restricted © confidential 33
Introduction to Anaconda distribution
Sensitivity: Internal & Restricted © confidential 34
Introduction to Anaconda distribution
Sensitivity: Internal & Restricted © confidential 35
Introduction to Anaconda distribution
Sensitivity: Internal & Restricted © confidential 36
Introduction to Anaconda distribution
Sensitivity: Internal & Restricted © confidential 37
Introduction to Anaconda distribution
• Click Start menu, search and open Anaconda Prompt.
• Issue python command and start using the interactive mode.
Sensitivity: Internal & Restricted © confidential 38
Introduction to Anaconda distribution
• Click Start menu, search and open Anaconda Navigator.
• In the Home page, you can find JupyterLab, Notebook, Spyder, Visual Studio Code
applications are installed and ready to use.
Sensitivity: Internal & Restricted © confidential 39
Introduction to Anaconda distribution
• Launch Spyder IDE.
Sensitivity: Internal & Restricted © confidential 40
Introduction to Anaconda distribution
Console to see
the output.
Sensitivity: Internal & Restricted © confidential 41
Introduction to Anaconda distribution
Write a script to print Hello World:
• File Save as Choose a location to save this file Change Save as type to Python
Files Enter a file name Save the file.
Sensitivity: Internal & Restricted © confidential 42
Introduction to Anaconda distribution
Save current file.
Create a
new file.
Run current file.
Open an
existing file.
• Click Run.
Sensitivity: Internal & Restricted © confidential 43
Introduction to Anaconda distribution
Choose the location in which your python files are stored and Click Run:
Sensitivity: Internal & Restricted © confidential 44
Introduction to Anaconda distribution
Output:
Sensitivity: Internal & Restricted © confidential 45
Thank you
Sensitivity: Internal & Restricted