Introduction
to
Python
Readable. Simple. Dynamic. Fast.
Powerful. In-demand.
Spotle.ai Study Material
Instructors
Mousum Dutta
Chief Data Scientist, Spotle.ai IIT Kharagpur
Spotle.ai Study Material
Spotle.ai Study Material
Spotle.ai/Learn
The demand for Python is growing….
Machine Learning Data Analysis
Python has
been the
fastest growing
language,
globally, over
the last few
years, fuelled
mostly by its
usage in AI and
Data Science
Spotle.ai Study Material
Spotle.ai/Learn
The demand for Python is growing….
Machine Learning
Data Analysis
The average
The case for Python
✓ High Usability
✓ Flexibility – Python allows easy cross-app integration and also inter-operability with other programming languages
✓ Readable and simple – Easier to learn, code and debug
✓ Large standardised library simplifying complex tasks ✓ Interactive mode with the
integrated, easy to use development environment Jupyter
Web Development
• Core Python Packages: Flask, Django Data Science
• Core Python Packages: Pandas, Matplotlib, StatsModels Text Processing
Core Python Packages: NLTK, TextBlob, Spacy Artificial Intelligence
• Core Python Packages: SciKit – Learn, Tensorflow, Keras Scientific and Numeric Computing
• Core Python Packages: NumPy
Python Use Cases and Libraries
Used By:
Spotle.ai Study Material
Python 2 vs Python 3
Python 2 Python 3
Legacy
Though used in 63% of software projects till 2017-18, its adoption is declining. As of 2019, the
latest version of Python 2, Python 2.7 is officially retired
Way Ahead
Uptick in adoption. New libraries are being for Python3
ASCII
Strings are stored as ASCII by default
UNICODE
Strings are stored as UNICODE by default
3/2 = 2
In Python 2, 3/2 is integer division or floor division. So Print 3/2 will print 1
3/2 = 1.5
In Python 3, 3/2 returns the expected 1.5. So Print (3/2) will print1.5
Print is a Statement
Print “Welcome to Spotle.ai”
Print is a Function
Print (“Welcome to Spotle.ai”)
Spotle.ai Study Material
Spotle.ai Study Material
Spotle.ai/Learn
Compiler vs Python Interpreter
Basis Compiler Interpreter
Input It takes an entire program at a
time
It takes a single line of code or instruction at a time
Output It generates intermediate object
code
It does not produce any intermediate object code
Working mechanism
The compilation is done before execution
Compilation and execution take place simultaneously
Speed Comparatively faster Slower
Memory Memory requirement is more due
to the creation of object code
It requires less memory as it does not create intermediate object code
Errors Display all errors after
compilation, all at the same time
Displays error of each line one by one
Error detection Difficult Easier comparatively
Spotle.ai Study Material
Spotle.ai/Learn 8
In Python, indentation is not just for
making it look pretty
In Python, indentation has well defined meaning. Indentation is used to define block of codes. See the below example.
If (1==1)
print (“All is well”) Else
print (“End of the world”) print (“Bye Bye”)
If (1==1)
print (“All is well”) Else
print (“End of the world”) print (“Bye Bye”)
This will print
All is well Bye Bye
The above piece of code will
consider print (“Bye Bye”) outside if-else
This will print All is well
But will not print Bye Bye
The above piece of code will consider print (“Bye Bye”) under else condition
Spotle.ai Study Material
In Python, everything is an object
Python is an object oriented language where everything is an object. Unlike Ruby, python objects are not necessarily sub-classable or have methods. They are objects in the sense they can be passed in functions or assigned to variables. class Myself def self_love(self): Print(“I am awesome”) Me = Myself() Me.self_love()
Here Myself is a class, the function self_love is called a method of Myself and Me is an object of type Myself.
Spotle.ai Study Material
Data Types and Operators in Python
Python supports 5 standard data types. Numbers
String List Tuple Dictionary
Python supports a wide variety of operators.
✓ Arithmetic Operators
✓ Comparison (Relational) Operators
✓ Assignment Operators
✓ Logical Operators
✓ Bitwise Operators
✓ Membership Operators
✓ Identity Operators
Spotle.ai Study Material
Setting up Python
Spotle.ai Study Material
Spotle.ai/Learn 12
Spotle.ai Study Material
Spotle.ai/Learn
Certificate Masterclass In
Python Fundamentals
Certificate Masterclass in Python – What
will you learn?
✓ Go from an absolute beginner to a confident programmer level with complete
understanding of Python basics
✓ Master the latest version of Python, Python 3 in 6 weeks
✓ Get adequate hands-on exercises to practise all your Python concepts.
✓ Cover fundamentals and basic libraries including Classes and objects,
Numbers, Strings, Basic Operators
✓ Practise Python through comprehensive quizzes with detailed notes to help you
understand solutions
✓ Build your foundation for more advanced programs including Data Science,
Text Processing, Machine Learning and Deep Learning using Python
✓ Understand career paths in Python and how to prepare for career opportunities
Spotle.ai Study Material
Learn Python In The Most Intense Course Ever: https://spotle.ai/learn/python
20
Interactive Videos with illustrative examples24/7
Access to chat and career support4
Live Classes With Instructors to learnconcepts first-hand
20
Quizzes to test your learning on the go7
Hours Of Lecture20
Practice sessions and real-life projectsLearn at your own pace with integrated
instructor support
Interactive Videos with illustrative examples
Quizzes to test your learning on the go
Hours Of Lecture
Live Classes With Instructors to learn concepts first-hand
Practice sessions and real-life projects
Access to chat and career support
15
Spotle.ai Study Material
Spotle.ai Study Material
Spotle.ai/Learn 16
Your Take - aways
✓ Certificate Of Completion.
✓ Integrated live projects and performance based internship. ✓ Membership of Spotle AI Alumni club with priority
access to courses, events and mentoring.
✓ Optimized career path fitment through AI.
✓ Personalised career
guidance and assistance.
Sign up for the Masterclass: https://spotle.ai/learn/python
Spotle.ai Study Material Spotle.ai/Learn