You are on page 1of 17

Introduction to Python

Programming
History

2022 - Python 3.10


Features
Working Environment
Anaconda (written in Python)
• Anaconda is a free and open source distribution
• Simplifies package management and deployment
• Package versions are managed by Package Management system Conda
• 1400 + data science packages for Python & R
• IDES – Jupyter, Spyder,R Studio
1. Data Science Libraries in Anaconda
▪ Data Analytics & Scientific Computing – NumPy, SciPy, Pandas , Numba
▪ Visualization- Matplotlib
▪ Machine Learning - TensorFlow, Scikit learn
Working Environment Cont…
2. Conda the data science Package & environment Manager
▪ Automatically manage all packages
▪ Work across all platforms (Linux, MacOS, windows)
▪ Virtual environments
▪ Download Conda Packages from Anaconda, Anaconda enterprise,
conda forge, Anaconda cloud
3. Anaconda Navigator
▪ Desktop Portal
Python GUI
▪ TKinter – Bundled with Python
▪ WXPython
▪ PYGUI – Light weight, cross Platform
▪ PYside – Nokia
▪ PyGObject – bindings for GTK+
▪ PyQt5 – bindings for QT application framework
▪ Kivy – cross-platform UI creation tool
▪ Glade
Why it is Slow?
1) Dynamically typed Language

2) Interpreted code is always slower


Takes more instructions in order to implement actual machine instruction

3) GIL (Global Interpreter Lock)

➢Allows only one thread to hold the control of python Interpreter


➢Bottleneck in CPU bound multi-threaded code [Even in multithreaded
architecture with more than CPU core]
➢Prevents CPU bound threads from executing parallel
Basics of Python
Comments
# Single line or inline comments
Data types
Python provides data types such as numeric, complex, strings and
Boolean.
It supports no type Declaration.
Numeric
Python has two numeric types int and float
Strings
• ‘Welcome’
• “Welcome”
Data types cont.….
Multiline strings – Triple quotes
“““Welcome to Python course.
You will learn basics to advanced concepts”””
Boolean
bool is a subtype of int, where True == 1 and False == 0
Complex
>>> complex (10,2)
(10+2j)
>>> x=10+5j
>>> x
(10+5j)
>>> type((10+2j))
<class 'complex'>
Keywords
Operators
(), {}, [] Tuple, List, Dictionary, set display
f (….), x [ :], X.attr Function calls, slicing, Attribute reference
** Exponentiation - Right to left associativity
x, -x Bitwise Not, Negative
*, /, //,% Multiplication, division, floor division,
Modulo division
+- Additive
<< >> Shift
& Bitwise AND
 Bitwise XOR
| Bitwise OR
in, not in, is, is not <, <=, >, >=, !=, == Membership, Comparison/relational
not Boolean NOT
and Boolean AND
or Boolean OR
lambda Lambda expressions
Operator Cont.….

>>>5 / 2
2.5
>>>7 // 3 #integer division
2
>>>7 % 3 #Remainder
1
>>>2 ** 4
16
Operator Precedence
x+y*z-c

x*y- z/c
Associativity
Exponent and Assignment - right to left
a ** b ** c is treated as a ** (b ** c).

Y**2**3

x=y=z=10

x+y*z/c
Reading Input and Printing output

str=input ("Enter any value")


print (‘output: ', str)

You might also like