What
Interpreted Functional Object Oriented
Simple-Syntax Fast - Inbuilt Libraries
Why
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”
Five
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
Variables
Methods
Blocks
class Identity
{
variables
static
methods
blocks non-static
}
Variables: Memory
Bharath
Syntax:
data_type identity ; 123 456
Example: 100
145672
int a = 100; a
Banking
Application
Non-Static Static
accountNumber bankName
123 456 Chase
balance
5000 10000
Comments or Doc Strings
“”” ‘’’
Files
Store Data
Text Files
Binary Files
Open
f=open(“fileName”,”mode”,”buffer”)
4096 or 8092
f.close()
Pickle
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 = True
X or Y
not X
X=True X=a>b
Assignment Operators
= a=10 a=x+y
+= a+=b a=a+b
-= a=a-b
*= 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(n-1)
Object Oriented Principles
Encapsulation
Inheritance
Abstraction
Polymorphism
Not only Python
Classes and Objects
Abstraction
I
N
T
Object1 E
R
Object2
F
A
C
E
TV
Ca
LAPTOP r
Cellphone
Abstract Classes & Interfaces
BMW
@abstractmethod
drive():
ThreeSeries(BMW)
pass
drive():
print(“God Speed”)
ABC class from abc module
Interfaces are Abstract Classes
Inheritance
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 Bus
IS-A
BMW AUDI VOLVO BENZ
Polymorphism
Poly Multi
Morphic Shapes/Behavior
Interfaces
Classes Complete Definition
Abstract Classes Partial Definition
Interfaces Complete Specification
start
interface car{
Car ride
stop
start
start ride
BMW
Honda ride stop
stop
public abstract
new X
class Honda implements Car
Multiple Inheritance
Complete Abstraction
List add Connection createStatement
get setAutoCommit
ArrayList LinkedList OracleConnection MySqlConnection
Parents
Respect
Love Wife
Bharath
Care
Children
Professional
Colleagues
Multi Tasking
Browser
Movie
Processor Player
Photo
Editor
Multi Threading
Browser
Movie
Processor Player
Play Video
Online Video Server
Player Buffer Video
Bank Teller
Receive Checks
Check Processor
ATM
Application
Process Checks
Customer
Mobile
InterThread Communication
Object wait() Obj
wait() t1
notify() notify()
t2
notifyAll()
Synchronized IllegalMonitorStateException
notified
time expires wait
interrupted
wait
Completes
Runnable
Running Dead
Polymorphism
POLY MULTI
MORPHIC SHAPES
OBJ2
OBJ1
OBJ3
Duck Typing
Duck Human
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 findall
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 urllib
Socket Programming socket
Send Emails smtplib
Socket Programming
socket socket
Client Server
connect bind
send/recv
listen
close
accept
send/recv
close
Sending Emails
create message
body
Client gmail
subject
from
to
smtpserver
login
send_message
quit