Python Course Slides - PPTX - AutoRecovered
Python Course Slides - PPTX - AutoRecovered
10
a = 10
f = 10.23
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:
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
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
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
New Object
Iphone X
Accessing Existing Objects Functionality
Vehicle
IS-A
Car Bus
IS-A
Poly Multi
Morphic Shapes/Behavior
Interfaces
start
start ride
BMW
Honda ride stop
stop
public abstract
new X
Complete Abstraction
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
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
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