0% found this document useful (0 votes)
29 views

1.1-1.4_Introduction to Python

Uploaded by

usharanr2
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

1.1-1.4_Introduction to Python

Uploaded by

usharanr2
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 50

Module 1: Introduction to

Programming with
Python
Dr. N.KANIMOZHI
Assistant Professor, Faculty of Engineering and Technology
Sri Ramachandra University, Chennai.
Outline: 1.1-1.4 Python Distributions,
Anaconda, Jupyter, Spyder

• Introduction to Python

• Python Distributions

• Jupyter Notebook

• Spyder

• Python Crash Course


Python
?Python is a general purpose programming language that is often

applied in scripting roles i.e. programming + scripting
language.
Program Scripting
A program is executed i.e. the A script is interpreted
source is first compiled, and
the result of that compilation is
expected
A program is a sequence of A scripting language is nothing
instructions written so that a but a type of programming
computer can perform certain language in which we can
task. write code to control another
software application
History

• Invented in the Netherlands, early 90s by Guido
van Rossum.

• Guido van Rossum is fan of ‘Monty Python’s Flying


Circus’, this is a famous TV show in Netherlands.

• Named after Monty Python.

• Python 3 version released in 2008 and


subsequent
releases happening after that.
Why Choose
Python?
What can you do with
Python?
What can you do with
Python?
Characteristics of
Python!!!
• Python is object-oriented
• Structure supports such concepts as polymorphism,
operation overloading, and multiple inheritance.
• It’s free (open source)
• Downloading and installing Python is free and easy.
• Source code is easily accessible.
• It’s powerful
• Library utilities.
• Third party utilities (e.g. Numpy, Scipy).
• It’s mixable
• Python can be linked to components written in other languages easily.
• Python and C/C++ integration is quite common.
Application of Python in Real-
World Scenarios
Python is used in virtually every industry and scientific field
that you can imagine, including:
• Data Science.
• Machine Learning.
• Web Development.
• Computer Science Education.
• Computer Vision and Image Processing.
• Game Development.
• Medicine and Pharmacology.
• Biology and Bioinformatics.
• Neuroscience and Psychology.
• Astronomy.
• Other areas such as robotics, autonomous vehicles, business,
meteorology, and graphical user interface (GUI) development.
Application - Data Science: Analysis and
Visualization
With a Python data visualization library, you
can create a wide variety of plots and visual
representations, such as:
• Lines, Bars, and Markers.
• Images, and contours.
• Subplots, axes and figures.
• Statistics (Box Plots, Bar Charts, and Histograms).
• Pie and polar charts.
• 3D Plots and many more!
The data visualization libraries:
• Matplotlib.
• Seaborn.
• ggplot2.
• Bokeh.

The data analysis libraries:


• NumPy.
• Pandas.
Application – Machine
Learning Machine Learning is an area of Computer Science that
creates systems that are able to learn on their own. This
type of system uses algorithms that are continuously
improved based on input data that helps the system
"learn".
These are two other popular Python libraries used for
Machine Learning:
• Keras – an open-source neural-network library written in
Python.
• PyTorch – an open-source Machine Learning library used for
developing and training neural networks.

You can find more examples of the applications of


Machine Learning in Kaggle, (https://www.kaggle.com/)
an "online community of data scientists and machine
learning practitioners" owned by Google. In this
platform, you can practice your Python and
Machine Learning skills by working on
projects and participating in competitions:
• Predicting lung function decline.
• Forecasting COVID-19 spread.
• Identifying videos with face or sound manipulations.
• Detecting fraud from customer transactions.
• And so on
Application – Computer Vision and Image
Processing
The goal of image processing is to process an
image, apply transformations to it, and return a
new version of the original image. In contrast, the
goal of computer vision is more complex
because it tries to make the computer understand
and interpret an image and its content.
With a Python library, you can perform operations
such as:
• Cropping, flipping, and rotating.
• Manipulating exposure and color channels.
• Detecting edges and lines.
• Adding filters and restoring images.
• Object and Event Detection.
• Facial recognition.

These are some awesome libraries for computer vision and


image processing:
• OpenCV and Pillow.
• SciKit-image.
• SciPy.
Application – Medical Image Processing and Deep
Learning
Python also has amazing applications in the medical
field. You will be surprised by how technology is being
combined with medical knowledge to provide accurate
and efficient diagnoses and treatments to patients.
With a Python library, you can perform operations such
as:
• Cancer Detection (Oral, Breast).
• Affected area segmentation for diagnose.
• Utilize of Histopathology, X-Ray, Ultrasound,
Mammography, Thermography.
These are some awesome libraries for deep learning
to diagnose medical images:
• Torch.
• Torchvision.
• Keras.
• Tensorflow
Installing
Python
1. Choosing suitable Python version

• Python is pre-installed on most Unix systems,


including Linux, Ubuntu and MAC OS X.
• But for Windows Operating Systems, user can
download
from the https://www.python.org/
• From the above link download latest version of python
IDE and install.
• Recent version is 3.8.* but most of them uses version 2.7.* only
( Python 2.7 will not be maintained past 2020.).
Installing
Python
2. Popular Python Editors

• Sublime Text
• Jupyter Notebook (https://jupyter.org/)
• Spyder (https://spyder-ide.github.io/)
• and so on.
Installing
Python
2.3 A compact Python
Distribution
Installing
Python
2.3 A compact Python
Distribution
• The
Condaopen-source Anaconda
is an open source package managementDistribution is the
system and environment easiest
management way
system to
that runs
perform
on Windows, Python/R
dependencies.
macOS and Linux. data
Condascience and
quickly installs, machine
runs and updateslearning
packages andon their

Windows,
Scikit-learn is aand
Linux, Mac OS
free software X.learning library, it features various classification, regression
machine
and clustering algorithms including support vector machines, k-means, and so on.
• With over 15 million users worldwide, it is the industry standard
TensorFlow : Python Deep Learning Library for fast numerical computing created and released by Google.
for developing, testing, and training on a single machine.
It is a foundation library that can be used to create Deep Learning models directly.
• ItNumPy
enabling individual data scientists to:
is a Python library which adding support for large, multi-dimensional arrays and matrices, along
• Quickly
with download
a large collection 1,500+
of high-level Python/Rfunctions
mathematical data science
to operate on these arrays.
packages.
• Manage
Pandas libraries,
is the most populardependencies,
python library that and environments
is used for data analysis.with
Conda.
• Develop and train machine learning and deep learning models with scikit-
learn, Tensorflow, and Theano.
• Analyze data with scalability and performance using NumPy, and Pandas.
Installing
Python
2.4 Package installation

• Run the following commands in Terminal (Ubuntu) or


in command prompt (Windows):
a) conda install 'package_name' (for anaconda distribution)
b) pip install 'package_name' (for python 2.7 distribution)
c) pip3 install 'package_name' (for python 3.* distribution).
How to Execute Programs in
Python?? (Procedure 1)
Step 1: Launch Spyder from Anaconda
Navigator

Launch from
here!!
Continue

Step 2: Open Spyder and Write Your
Assignement

Write your Assignment in


Program Console
Continue

S tep 3: Save your
Assignment

Save Your Assignment from


File option with .py extension
For Example:
basic.py
Continue

S tep 3: Execute the
Assignment

Execute your
Assignment

Displays the Result in Python


Console
How to Execute Programs in
Python?? (Procedure 2)
Step 1: Open Anaconda Prompt
Continue

Step 2: Open the Directory where you have saved
the Program
Continue

Step 3: Run the program by preceeding python followed by the name
of the program
Todays
 Install
Task
all pre-requisites for proper execution of
python
the Follow the word file Python
programming.
Installation .

 Perform simple basic operations of python as instructed in


the (upcoming) slides for taking the sense of the
programming
Data Science and
Tools
Some Basic Data types,
Variables, and Operators in
Python
Continue

Data Types
Continue

Data Types
Tutorial
s
Continue

Continue

Variable Assignments
Continue

Variable Assignments
Continue

Variable Assignments
Continue

Variable Assignments
Continue

Variable Assignments
Tutorial
s
Continue

Continue

Continue

Continue

Comparison Operators and
Boolean
• In this lecture, we will be learning about Comparison
Operators in Python.

• These operators will allow us to compare variables and output


a Boolean value (True or False).
Continue

Comparison Operators Operand
s: a=20 b=1
0
Operator Description Example
== Checks if the value of two operands are equal or not, if yes then (a == b) is not true.
condition becomes true.
!= Checks if the value of two operands are equal or not, if values are (a != b) is true.
not equal then condition becomes true.
<> Checks if the value of two operands are equal or not, if values are (a <> b) is true. This is
not equal then condition becomes true. similar to != operator.
> Checks if the value of left operand is greater than the value of right (a > b) is not true.
operand, if yes then condition becomes true.
< Checks if the value of left operand is less than the value of right (a < b) is true.
operand, if yes then condition becomes true.
>= Checks if the value of left operand is greater than or equal to the (a >= b) is not true.
value of right operand, if yes then condition becomes true.
<= Checks if the value of left operand is less than or equal to the value (a <= b) is true.
of right operand, if yes then condition becomes true.
Tutorial
s
Continue

Logical Operators
Operator Description Example
and Called Logical AND operator. If both the operands are (a and b) is true.
true then then condition becomes true.

or Called Logical OR Operator. If any of the two operands (a or b) is true.


are non zero then then condition becomes true.

not Called Logical NOT Operator. Use to reverses the not(a and b) is false.
logical state of its operand. If a condition is true then
Logical NOT operator will make false.
Tutorial
s

You might also like