What
Interpreted Functional Object Oriented
Simple-Syntax Fast - Inbuilt Libraries
Wh
y
Easy to learn/use Performance
Rapid Development Dynamically Typed
Community Third party libraries
CherryPy boto
DataTypes
10
a=
10
f=
10.23
s = “You are the creator of your destiny”
Fiv
e
None Type an object that does not contain any value
Numeric Types int,float,complex
Sequences str,bytes,bytearray,list,tuple,range
Sets
Mappings
Building Blocks Of a Java Application
Class
Variable
s
Method
s
Blocks
class Identity
{
variables
static
methods
non-static
blocks
}
Variables: Memory
Bharath
Syntax:
123 456
da identity ;
ta 100
Examp_t
le: yp 145672
int a = 100; a
e
Banking
Application
Non-Static Static
accountNu bankNa
mber
123 456 me
Chase
balance
500 1000
Comments or Doc Strings
“” ‘
” ’
’
Files
Store Data
Text Files
Binary Files
Open
f=open(“fileName”,”mode”,”buffer”)
4096 or 8092
f.close(
)
Pickl
e
f=open(“fileName”,”mode”,”buffer”)
4096 or 8092
f.close(
)
Modes
w r a w+ r a+ x
+
wb rb ab w+b r+b a+b xb
Logical Operators
X and Y = Tru
e
X o Y
r
not X
X X=a>b
=
Assignment Operators
= a a=x+y
+= =
a+=b a=a+b
1
-= a=a-b
0
* a=a*b
=
/=
%=
**
=
//=
Arithmetic Operators
+
-
*
/
%
*
//*
Comparison Operators
==
!=
>
<
>=
<=
Recursion
factorial(3) = 3*2*1
factorial(3) = 3 * factorial(2)
factorial(2) = 2 * factorial(1)
factorial(1) = 1 * factorial(0)
factorial(0) = 1
factorial(n) = n * factorial(n-1)
def
factorial(n)
if n==0:
return 1
else:
return
n*factorial(
Object Oriented Principles
Encapsulation
Inheritance
Abstraction
Polymorphism
Not only
Python
Classes and Objects
Abstraction
I
N
T
E
Object1 R
F Object2
A
C
E
T
V
LAPTO C
P a
r
Cellphone
Abstract Classes & Interfaces
BM
W
@abstractmethod
drive()
:pass ThreeSeries(BMW)
drive()
:
print(“God Speed”)
ABC class from abc module
Interfaces are Abstract Classes
Inheri
tance Exiting Object
New Object
Iphone X
Accessing Existing Objects Functionality
Updating Existing Objects Functionality
Iphone X++
Re-Usability and IS-A Relation
Vehicle
IS-
A
Car B
IS- us
A
BM AUD VOLV BEN
W I O Z
Polymorphism
Poly Mult
i
Morphic Shapes/Behavior
Interfaces
Classes Complete Definition
Abstract Classes Partial Definition
Interfaces Complete Specification
Car
start
interface car{
ride
stop
BMW start
Honda
start ride
ride stop
stop
public abstract
new X
class Honda implements Car
Multiple Inheritance
Complete Abstraction
Lis add Connection createStatement
t get setAutoCommit
Arr LinkedLi OracleConnection MySqlConnection
ay st
Lis
t
Parents
Res
pect
Love Wif
Bharath e
Care
Children
Prof
essio
nal Colleagues
Multi Tasking Browser
Processor Movie
Player
Photo
Editor
Multi Threading Browser
Processor Movie
Player
Online Video Play Video Server
Player
Buffer Video
Bank Teller
Check Processor
Application
Receive Checks
ATM
Process Checks
Customer
Mobile
InterThread Communication
Obj
Object wai
t()
wait( t1
)
notify(
notify(
) t2
)
notifyAll(
)
Synchronized IllegalMonitor
StateExceptio
n
notified wait
time expires
interrupted
wai
t
Runnable
Running Completes Dead
Polymorphism
POL MULT
Y I
MORPHI SHAPES
C
OBJ2
OBJ1
OBJ3
Duck Typing
Duck Hum
an
talk talk
def callTalk(obj)
obj.talk()
Dependency Injection
Engine
Flight
Engine
AirbusEngine BoingEngine
+
Method Overriding
BMW
start(
)
ThreeSeries FiveSeries
start() start()
Regular Expressions regex
search
pattern r’\d+\
b’
validate
email password
match
search
re findal
l
split
sub
Sequence Characters
\ \ \ \ \ \ \ \ \
d D s S w W b A Z
Quantifiers
+ * ? {m {m,n
} }
\d+
Special Characters
\ . ^ $ [… [^ (… (R |
] …] ) S)
URL and Images urlli
b
Socket Programming socket
Send Emails smtplib
Socket Programming
Client Server
socket socket
connect bind
send/recv
listen
close
accept
send/recv
close
Sending Emails
create message
Client gmail
body
subject
from
to
smtpserver
login
send_message
quit