Python Course Slides - Key
Python Course Slides - Key
a=
10
f=
10.23
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
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
New Object
Iphone X
Accessing Existing Objects Functionality
Vehicle
IS-
A
Car B
IS- us
A
BM AUD VOLV BEN
W I O Z
Polymorphism
Poly Mult
i
Morphic Shapes/Behavior
Interfaces
BMW start
Honda
start ride
ride stop
stop
public abstract
new X
Complete Abstraction
Children
Prof
essio
nal Colleagues
Multi Tasking Browser
Processor Movie
Player
Photo
Editor
Multi Threading Browser
Processor Movie
Player
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
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