Python Introduction
Python Introduction
Python Introduction
Copyright © LEARNXT
Introduction to Python Programming
Copyright © LEARNXT
Introduction to Python
Copyright © LEARNXT
Python - Introduction
Python is a high-level language with which one can do a lot with relatively little code
Copyright © LEARNXT
Python - Introduction
Python is an interpreted, object-oriented, high-level programming language with dynamic
semantics
Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of
program maintenance
Python supports modules and packages, which encourages program modularity and code
reuse
Copyright © LEARNXT
What can Python Do?
Python can be used on a server to create web applications
Python can connect to database systems. It can also read and modify files
Python can be used to handle big data and perform complex mathematics
Python can be used for rapid prototyping, or for production-ready software development
Copyright © LEARNXT
Why Python is Preferred for Data
Science
Copyright © LEARNXT
Python Preference
Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc)
Python has syntax that allows developers to write programs with fewer lines than some other
programming languages
Python runs on an interpreter system, meaning that code can be executed as soon as it is
written. This means that prototyping can be very quick
Copyright © LEARNXT
Difference Between R and Python
R Python
Primarily developed to perform statistical and data analysis Provides a general approach to Data Science for deployment
and production
Built by statisticians and encompasses their specific language General-purpose language with an easy-to-understand syntax
Used primarily in academics and research and is great for Used by programmers for data analysis / statistical techniques
exploratory data analysis and for data science applications
~12000 packages available in CRAN. You can find a library for Provides cutting-edge API for AI / ML. Most of the data science
whatever analysis you want to perform job can be done with 5 libraries: Numpy, Pandas, Scipy, Scikit-
learn and Seaborn
A tool to carry out statistical and data analysis A tool to deploy and implement machine learning at a large-scale
Heavily dependent on libraries Python codes are easier to maintain and more robust
Mostly run locally Can be integrated with apps and production environment
Uses RStudio for IDE Jupyter Notebook and Spyder are most popular IDEs
High learning curve Not as many libraries as R
Copyright © LEARNXT
R Vs Python
Copyright © LEARNXT
Python Preference
Best tool for Machine Learning integration and deployment at large scale
Gained popularity for its code readability, speed, and many functionalities
Many Python IDEs to choose from which drastically reduce the overhead of organizing code,
output, and notes files
Copyright © LEARNXT
Python Preference
Can be well-integrated with apps in a production environment
Statistical gap between R and Python are getting closer and most of the job can be done by
both languages
Copyright © LEARNXT
Installing IDE for Python
Copyright © LEARNXT
IDE
A code editor is a tool that is used to write and edit code. They are usually lightweight and can
be great for learning
However, once your program gets larger, it is better to use an IDE to test and debug your code
It usually provides features such as build automation, code linting, testing and debugging
Thus, IDEs can significantly speed up your work. The downside is that IDEs can be
complicated to use
Copyright © LEARNXT
Running Python
Two ways to run Python programs
Using Shell
Jupyter
Spyder
PyCharm
Jupyter Notebook is an open-source web application that you can use to create and share
documents that contain live code, equations, visualizations, and text
The name, Jupyter, comes from the core supported programming languages that it supports:
Julia, Python, and R
Copyright © LEARNXT
IPython Shell
Command shell for interactive computing in multiple programming languages
Python Script
Copyright © LEARNXT
Anaconda Distribution
Anaconda is a conditional free and open-source distribution of the Python and R programming
languages for scientific computing that aims to simplify package management and deployment
Distribution includes data-science packages suitable for Windows, Linux, and macOS
It is developed and maintained by Anaconda, Inc., which was founded by Peter Wang and
Travis Oliphant in 2012
It is also known as Anaconda Distribution or Anaconda Individual Edition, while other products
from the company are Anaconda Team Edition and Anaconda Enterprise Edition, both of which
are not free
Copyright © LEARNXT
Python IDE
Copyright © LEARNXT
IDEs for Python Within Anaconda Navigator
Copyright © LEARNXT
Install Anaconda – Jupyter Notebook
Install Anaconda
Copyright © LEARNXT
Installing Anaconda – Jupyter Notebook
Install Python through the anaconda distribution https://www.anaconda.com/distribution/
Copyright © LEARNXT
Install Anaconda – Jupyter Notebook
Download the Python 3.8 version (or the latest available version) for Windows / Mac / Linux as
applicable
Copyright © LEARNXT
Installing Anaconda – Jupyter Notebook
Open Anaconda Prompt / Terminal
Copyright © LEARNXT
Anaconda Navigator – Jupyter Notebook
Open Anaconda Navigator
Copyright © LEARNXT
Install Anaconda – Jupyter Notebook
Click Launch under Jupyter notebook
Copyright © LEARNXT
Jupyter Notebooks - Basics
Copyright © LEARNXT
Jupyter Notebook
Jupyter Notebook is an open-source web application that allows you to create and share
documents that contain live code, equations, visualizations and explanatory text
Copyright © LEARNXT
Understanding the Jupyter Notebook
Copyright © LEARNXT
Create a Jupyter Notebook
Create your first Jupyter notebook
pwd
'C:\\Users\\user\\python programming’
import os
Copyright © LEARNXT
Create a Jupyter Notebook
Change the working directory
os.chdir('D:/Jupyter Notebook/Analytic_toolkit')
pwd
'D:\\Jupyter Notebook\\Analytic_toolkit'
Copyright © LEARNXT
Using the Print Command
Using the print command
print("Hello World")
Hello World
2**2 = 4
Copyright © LEARNXT
Using the Print Command
print(1+3) i=1+3
4 print(i)
pi = 3.1415926 4
print(pi)
3.1415926
print(message)
Hello, world
Copyright © LEARNXT
Summary
Python is an interpreted, object-oriented, high-level programming language with dynamic
semantics
Python provides a general approach to Data Science for deployment and production while R
was primarily developed to perform statistical and data analysis
It gives the advantage of higher speed and interactivity with Jupyter notebooks
Jupyter Notebook is an open-source web application that you can use to create and share
documents that contain live code, equations, visualizations, and text
Copyright © LEARNXT
Additional Resources
McKinney, W. (2013). Python for data analysis. O'Reilly Media.
Beazley, D., & Jones, B. K. (2013). Python cookbook: Recipes for mastering Python 3. O'Reilly
Media.
Copyright © LEARNXT
e-References
Welcome to Python.org. (n.d.). Python.org. https://www.python.org
https://www.w3schools.com/python/python_intro.asp
Copyright © LEARNXT 36
Any Questions?
Thank you
Copyright © LEARNXT
Copyright © LEARNXT