Introduction to Python for Data Science
Section 03 - Non-Specific M.Tech AIML
BITS Pilani
Pilani|Dubai|Goa|Hyderabad
Prof. Upendar Mendu
1
1
Agenda for CS #1
1) Ground Rules
2) Introduction to DSECLPFDS / AIMLCPFDS
o Motivation & Objective
o Courseware, LMS Walkthrough
o Books & Evaluation components
o Pedagogy for this course ?
3) Course Schedule
4) Getting started with Module 1
5) Q&A
6) Feedback
2
Ground Rules!
⮚ Mentally present – Listen! Observe!!
⮚ Keep your questions for the Q&A section / Discussion Forum
⮚ Use the Discussion Forum in LMS Portal effectively
⮚ Do not post unrelated messages in MS Teams. React using the “Like” feature if your
intended message has already been posted.
⮚ Solve the exercises regularly! Connect!
⮚ Go that “extra mile”
3
Motivation for this course ?
Motivation
⮚ As of now, Python is one of the most widely used programming
languages in the Data Science field.
⮚ Data Scientists just love Python!
⮚ Python is easy to learn & has a great community for support!
⮚ We would use Python for all the assignments / case-studies (For all
the subjects in MTech DSE / MTech AIML).
4
Why learn Python?
High-level, general-purpose, interpreted language
Widely used in data science, ML, AI, automation, and web
Simple syntax, quick learning curve
Rich libraries and vibrant community support
5
Python vs Other Programming
Languages
Feature Python C/C++ Java R MATLAB
Ease of Use High Low Medium Medium Medium
Learning Curve Easy Steep Moderate Moderate Moderate
Speed Slower Very Fast Faster Slower Moderate
ML/AI Libraries Excellent Poor Fair Good Moderate
Community Massive Large Large Good Niche
6
Real-World Applications
Domain Example Uses
Healthcare Disease detection, image diagnostics
Finance Fraud detection, trading bots
Marketing Sentiment analysis, recommender
systems
Agriculture
Education Yield prediction,
Intelligent remote
tutors, sensing
learning analytics
7
Course Objectives
What is this course about ?
⮚ Introduce the fundamental programming concepts of Python
⮚ Enable you to solve data problems using Python
⮚ Act as a kick-start/bridge for participants of the M.Tech DSE/AIML programme who
are new to Python.
What is this course not about ?
⮚ Comprehensive, in-depth discussion about Python programming.
⮚ Comprehensive, in-depth discussion about data analysis using Python and related
packages, libraries, and tools.
8
Courseware
⮚ Available on canvas (Home page).
9
Text Books
Charles Severance: Python for Everybody, Jake VanderPlas: Python Data Science
Exploring Data in Python 3 Handbook
eBooks of both are made available in Canvas (Course Files Books).
Do not publish these on the Internet. For our use, we have got permission from the authors to use the eBook.
Note: These are the prescribed ones. Please feel free to explore any Python materials that suits you.
7 10
Evaluation Components
⮚ This course is NOT evaluated !!
⮚ You will not have any exams for this course
⮚ Nevertheless, there would be some exercises for you to try and hone
your skills: [No need to submit].
⮚ These will be on Canvas so you get accustomed to the Canvas LMS.
⮚ There will be “Assignments”
⮚ There will be “Quizzes”
11
Pedagogy for this Course
Step 02: Explore
o You explore the
Step 01: Class Session additional Step 03: Doubts
o We learn Fundamentals! notebooks. o Put your queries in
o Get your hands Discussion Forum.
o Look at few examples
dirty with Python o Peers and TA to
for each concept. o Practice more answer …
examples foreach
concept.
Non-Beginners: You can directly start with Step 02 and also use this phase for
additional learning which might help in future … You play an important role in Step
3 as well in answering your peer’s queries. 9 12
Today’s Schedule
Today – S1 (5:30-8:30 PM)
o Motivation & Agenda
o Python Basics
o Setting up Python Environment
o Package imports
o Data Types & Type Casting
o Variables, Expressions & Statement
13
Program & Programming Language
Computer Program
⮚ Set of instructions that perform a specific task executed by computer
⮚ Required by computer to function
⮚ Written by programmer using programming languages
⮚ Like C, C++, Java, Python etc.
⮚ Executed with compiler and interpreter
# This is a simple program to check if a number is even using Python
number = int(input("Enter a number: "))
if number % 2 == 0:
print("The number is even.")
else:
print("The number is odd.") 14
Python as a Programming Language
Why Python ?
Worldwide, Python is the most popular language
… Source : http://pypl.github.io/PYPL.html
15
Python as a Programming Language
Python Touchy Feel Properties
o Designed by Guido van Rossum around o Open Source
1990 o copyrighted but use not restricted
o Not just a scripting language o owned by independent non-profit, PSF
o Mature (30+ years old)
o Easy to learn, read, and use
o Supportive user community
o Extensible (add new modules)
o plenty of good books, too
o Highly readable o Active user community
o Latest Version 3.11.x o Simple design, easy to learn
o Most fond of language for Data Scientists o reads like “pseudo-code”
o Suitable as first language
o Suitable as last language :-) (Hopefully)
16
Python Applications
17
Python Ecosystem
Components of Python World :
⮚ Core Python
⮚ Distributions Core Python
⮚ Frameworks / IDEs o Programming Language itself
⮚ Third party Libraries o Some standard modules are available
o Other packages needs to be explicitly installed
Python Distribution
o Python + packages
o Majority of packages, libraries are already
available
o Package management is simplified
o Anaconda from Continuum Analytics
o IPython and its IPyKit variant 18
Python Ecosystem
Frameworks / IDEs Third party Libraries
o Use frameworks to create code and
develop applications o Makes life of developers very simple
o Provides a defined structure to the developers o Just need to know the right library to carry
so that they can focus on the core logic of the out a task
application rather than on other elements
• NumPy
o Python web framework
✔ Django • Scipy
✔ Web2py • Pandas
✔ Flask • Matplotlib
o Python IDEs • Seaborn
✔ IDLE • Bokeh
✔ PyCharm • ScikitLearn
✔ Spyder • And List goes on …
✔ Jupyter Notebooks
19
Python Installation
Three Ways :
o Install Python directly
– Install the Python language with installer
– Need to install other packages explicitly using pip install
– https://www.python.org/downloads/
o Use Python distribution
– The open-source Anaconda Distribution is the easiest way to perform Python coding
– Works on Linux, Windows, and Mac OS X
– https://docs.anaconda.com/anaconda/install/windows/
o Use Cloud based services
– The simplest of all but needs internet connectivity to use
– Microsoft Azure Notebooks
– Google Collab
20
Python Installation
Installing Python on Windows
Step: 1 To download and install Python, go to Python's official website
http://www.python.org/downloads/
Step: 2 When download is complete run .exe file to install Python.
21
Python Installation
Step: 3 You can see python installation
Step: 4 when installation was complete you can see message “setup was
successful” on screen.
22
Python Installation
• IDLE Development Environment
• Integrated DeveLopment Environment
• Text editor with smart indenting for creating python files.
• Menu commands for changing system settings and running files.
• How python runs
23
Programming Modes
How to execute python program: By using Python Interpreter, we can execute
python programs in 2 modes. They are:
1. Immediate mode: (in windows)
In the mode, you type Python expressions into the Python Interpreter window, and
the interpreter immediately shows the results.
2. Script mode (in windows)
we can open IDLE python then click on file, open new file and we can write python
program and save as filename.py. After that ,to run this program press F5 button or
click run button click Run module.
24
How to install Anaconda software
in windows
• https://www.anaconda.com/distribution/
• Anaconda is not an IDE, Anaconda is a Python distribution, (including for
commercial use and redistribution). It includes more than 400 of the most popular
Python packages for science, math, engineering, and data analysis.
25
How to install Anaconda
software in windows
26
Python IDE - Spyder Environment
27
Integrated Development Environments
(IDE) for Python
Common
IDE’s:
Our Favourite (For WILP Programme):
o .py is a regular python file. It's plain text and
contains just your code.
o .ipynb is a python notebook and it contains the
notebook code, the execution results and
other internal settings in a specific format.
28
Input / Output with Python
⮚ print() can be used to output a message
⮚ input() can be used to enter an input to the python program.
⮚ # can be used to provide comments.
⮚ (triple quotes) can be used to write documentation.
Demo:
o Let’s see how to launch Jupyter Notebook
o See the basics of Notebook
o Practice some I/O statements and comments. 29
Basic Code Constructs
Imports:
⮚ Import in Python is similar to #include in C/C++. Python modules
can get access to code from another module by importing the
file/function using import.
⮚ Ex: import math
⮚ print(math.pi)
Variable
⮚ A Python variable is a reserved memory location to store values. In
other words, variables are containers for storing data values.
⮚ Python has no command for declaring a variable.
⮚ A variable is created the moment you first assign a value to it.
⮚ Ex: a = 100 30
Data Types in Python
Immutable
type() can be used
To find the data
type
31
Data Types in Python
type() can be used to find the data type
32
Post your queries in the Discussion Forum!!
33
Feedback
:5
:3
Thank You for your time &
:1
attention !
Contact : upendarmendu@wilp.bits-pilani.ac.in
34