ATOEMION tp Puthon @
ANstery python +
* 1984 Guido van Rass ;
ee wale oh mary) Atanted. deydoping Pigthon
by Prrjeck Guning chatstrna, holidou. ob
Cul fy Netherlands
* 199) bist eo ; ae
1 bivst public “Telgase » pipthon 0-4-0, included tthe
“pinctions 1 &Xception handling ond obec oriented.
Programming: ' }
meant Python to tdeased sith seotures like
Medutur — and _exeption handling
%* 4000 python elo tntroduad Kt ‘commprehenforn
and gartoage cottedtion ‘but faci beackunaad
Compakantitty Issues: ’ ;
* 8008 python 3:9 ieieastd wht atgnigicant tone
verments Ake between unicode handling and deax
syntax was not backward cormpattote: /
% Q0aO -end of tie or pyenen, Bes maareting & eu
warnistion +o python 3+x: i
% Prevent, pytnon “rernainn a Jeaiding’ Janquage tn dato.
4diena, machine Jearning , web development yond. othe
oftware enginetring due to ts
| stobistical analysis, Wd th,
Applications : Data. poocusing
visual “fepresentotion jor (decision -making: ; ,
€x: Business Gel ie doshboards trend fereasting:.
8 Machine “easing and ne
Lib + Tensorstow , pytorch , AdKe -leaan , FerOs
Appi: “Putonnatting rep ekitive, +touks tike porn 1 Flog: dolby
any and “ating:
ee: eee joustomo.bed stporting: u
Ww Automation and wiping § CRIP) updo! f
5) Cybersecuntty ,
9 ot and Numente e computing, ,
*) Game deepen : ere ore 5
8) Financiot technology . od oon
Y Intemet of Rae ae ioe
10) ANeatineare and Bioinformatics: seitpa of 9 wv
Python Basic, data types
yp Numeric Aypet
Snkegers, dint," i
9%) age «as
print @ age is ages and tts type sts ¢ tupe caged 4")
b) floor C4 toor)
Pala 19-44
print C4" price is dpitenty and. jits type: 1s) 7 type pray"OLcomplex e
Aum - 34 44)
7 Te jpe (nur 4")
PEGE Humber is tau and ts type'ts {type ¢
@) sing str) te
Name = “phn Doe”
PHOECE™ Name 1S dnarey! and
ype, fs A type (nam
3) Boolean ( booty : “
cin toa
iS- achive = Hue
dive)?
Prine C4" pe. active is dis. ae and its ne eed (sa. dt
Hy tise Uist) SS
Mutable ordued Colletti:
fut ts = (" apple", i banana”,
“fruits. aktend (
‘print ¢#
” + chery
range)
“rut ts ftruie y nd
S)Tuple Tonos
He type is Ltype Chuits) ys)
Smmnutabte » Odea _ltcKon,
Coordinates» | (0, &0, 30),
prineca" Coordinate : 1000
(oordinaresyy?y’ <°
dinars and Hts type isirttype
6) Dictionary (dcr)
Key -Value) mutable
Ppuson = q* Name": “Alice, Nage":30 5:
Pason £» Jocation) = “New York”
> dese 4")
FIDE CE" person: X person § andl its type ¥ type ‘persons
Sek (Sey yt
tnordaied , unique ebrnents
unique numbers = 11,233,235and.
PoUTEAT UNIQUE TUM DES © TM tae
ype (unique - numbers) 4")
® None-type (None type
CSULt = Hone
PrineCt" yecuit : Cresult) and He type is CtypeC resut yy
4), Bytes (bytes) ‘ mt ne
byte. dota. b"+Heno"
print (4 wyte data: { byte-data ae
byte-dakady" )
its types typ,
thont : ae
Python & the — populor programing
gum € colened ON 1981.
fd
Created by Guido van Res:
Te ts Mointy usec por tot-development, Macht,
leasning , doko. ssdena and 40} tare developrrent and
aystern aeripting.
Python works on ty yerent platpowm like «
window mac linet And pytnon hax imple Syntax
Amilo, +0 tne engtish lounguage : :
“python ‘can be’ ‘Gyeated’ to procotuxiol = WOH, Ob
Oriented, vay » “junctional way.
r
Python “Applications: Hes Loa
Web and fntunee development , Adj twa deve
Ment, data base acess and text of “desktop qv3
applications, Network POgranting adentiytc and num!
b
usingss Opplications, games and sD Graphics, education
Pytinon Sclemitgtenc: ' Ue,
The name given ~to vantables | classes smmethod!Se i aren
Rules, stor Sdentizion:
O Tolentifier Caninot * be a Keyword and ‘Tdentipiens one
Case zersitive and it can have a Aequents. of letters
and Algtts: Tt Must’ “beatn woth letters or underae
aid“ -the first) letter Of an ‘identigier cannot ibe
a ‘aIgit! oinek ; we can't use Apedal xymbols @4 fy
Python commands » *
ae ’ 9s
Ws Aingle tine, Cornmands
we wt
> multi
\tne Commands:
x Variable’ "5" gf © storage aro. which stove “tne
Valse “or Ingovimation 97
Python prgum .€x + vie
a= int input (" Enter ~tne sist number :*))
Bb 8Type casting: Vaxiable +
oe eee Varfabla ate used’ ‘to
Xt as "Io"
R ing, C10 Atore sthe, date:
b= int ("29")
Print (+b) ples Sntendation> —° :
Olp + 35 Seah ae gy white apace OF TOP APta
’ ) Anowa be. provided. baseol,
Spy dlunober : . on the ge da condtton:
“Cr ga 2 ois: ar
enta lost —ordleh Prine ("13 is qecater">
yy tia a
Sage as rire ie qreaters),
eo pee te (6pan)» gnrendation :
BASH 67 po aa’ Ops 12-45 greater,
OQXZ XI rs Aquat
Trin nis Kind of nue te spy ndimnben, |
jeg?) 36
Pigthon operators ;
Operators v ares: ' -spetiat’ -2eyro ols) “that perform
©paations on variable and values: :
eredconasal ee
10 varues
b<10
print (at). , tee
" (a+ea0>
“Wipes | opuoctor : one d
SrSpe iol operator,
&x:
DMthmetic operator
D-Assignment operator sy spt
*) Cormparation oO puator
7) togicat op erator
L ©) Bitwlse gpaator=e
cavithmeric operators are used “tO perjorrn mathemati
cal operators — tike, addition, ubraction, raultiplication ete:
a
ee
ee opdation”
Addttion
Subyaction,
Murtipticakion
division,
low division
js Meclula etivigion
KS Povo ss
——$__—_]
Stanment operator :
‘Assign tthe dota or value fom. “the! variable
Q=t9
b-a0
At=b
b-bra0
CX =10
print (@
print (b>
print (o>
3) Compouotion operitor :
Compane
awo values OF
boolean resutt
a:
True or false
rat emaht-t
yoxiables
Fate ee ere, He, ne a ae “the operons:
and yetun a
greater “than
legs than
oy tater than *
tec eae than ®Ge :
aio Gd asio ui A210
b-a0 bse bd
TY a-io 54 ay 210 ; ay 7:10
print (ay pint (a) Print (by
else : else
print (b) Me ane (bd ‘ prin (ay
Op: 10 lp + ao “i Op: ao
ce “false “True
togtcal operators ae
Logical operators are ‘used 40° Check vohetiner op
expression is tue OF false atiney ane “Used ty
decision making:
“Ruth table:
[ee
Gemie bie asp f :
ast aaa ;
dele Ops 10
C=
Y arb:
print (a
else:ntas foe
2) A=10
bas
e:3
yar eb Ov CK =I}: :
print (a)
else:
print co
Op +0
3024
F4 noe oO
print
else
print ("9")
2 Get one — inpuk qronn the use, afind tna Number
is divisiole by 3: and &
2 Ge one fnput 40m Sine user check “that
pumber is 16 ox above 1s, 60 ov below 60, 24 the
condition t tue tne — output Arouid be agile
jos vote, flbove 60 ~thun the poor ig geniov
Citizen below 18 not dligitte 4or vole «
D4ind vowed or nor,Bltwise Operator:
Caw
“The Opuators axe!
¢ - Gitwise and
1 + Bitwise 02
~ binary value Cte or -falsey
~ - Bitwice NOT
A ~ @itwise xR
2? - Bitwise signt shiqt
Le Bitwise qt vit
alb |agb| afb | arb
i l t y oO
\
i 0 ° '
oft 0 1 ’
oo 0 Oo Oo
i BTUAATLIT sors oe a.
oe Owe we Is.
DY O=1g 4
bey aa) ro l
1
0:80 326 8 Ya
oo. \ 0} age
find age, oo
al doO1 0 0
cab '
Olp:
4 age
oeSpee fal Oper :
Operator
is
is* not Nasty :
Used to check HY tp valua are located at thes,
Aome Memory location’
issue, Y the open are idlentiad veer, to rtne
Same object: BRAC
is not: do not Teen to “the Aame Obj ear ‘
ee
Q="Helo — (fs)
b= "Alello"
pint (a is &)
sy Op + “ue sori Me
a Met et tie noty
b= "Hetto” i
prtint Co 1s nok » .
Opt Tue, :
~fioal opaaior o a rember ship Spar:
Merberdhip Operator “ic ured -to roe tot othe
Aequence pretent ip ~the Object do ried
ees
in not Ty oou
+ Ykturns +0 a Aecyuernes ud, she » apie values
Present in “the object *
Tot TO Te iS MOE pretenk Th te objectsRue
Of the charac is praent in the objeck.
in not:
"= false
% the charac is not pract Ws rte ,
txt K by idk
ass
b:4
Rp 574 stash}. at Dae
4 pot Orb: §
4
Print ta)
Op:
Print (@) = ©
Conditional Atatements :
dye ia
1% python we use this when Tang One
OX tp be executtd ard TY one, _ Ondition & yas
it goa not condition thar is aif
& dse:
Sh python we use elte When none
Above — condi-tions are pe, ier ase woh be oe
td. oa else is + op ticnal
» 4 Atatement +
Syntaxs
4 condition :
+t body 04 tine" a statementprint (@
pring (ORD
aukput +
'o
K
Arasornent ‘
Jager
+ iy oe
SYNTAX!
4 condition:
at body 04 tne i een ue
elie: —
a tady 04 Ane" "eee stienk
[are SB pei eae el
Syntax:
S{ condition 1:
Corda 043 Ouker Yo Statement
Y condition wy:
7 Body Q| inner 4 Atatement
else :
Fa :
fooly of tmner else stoserrent
else : es
Ea \
Body oF out else statement -
Os ment,
Crample:
Harb;
ty are;
Print ("a ts big’)
Clty boc atte
PMOE Cb bk bigh) :
ase:
PRE Ce big")
else:
Print: (nothing)
lp: False Scania
* bahite loop) ; te
Execute again and again in the body’ a lop
until it becomes Faber
a:@ fo
wmtso
while i465? .
a wo hele: 4 2tOivo
print cy aoe
Fe it 4 Tht o
e pint Go
output 4 oulgses
( sidan}
2 q
3 c
a OF wi be ptineA™, ey
5
ox
4) Sur of natural numbers:
fi) Reverse the numbers:
iin find the count or digit - eee er
‘w find tne ~foctovial number using while loop 1
Wind Aum a} digit my CAS") Naqad)
w Arntong,
Answers: eee
> Sum of n natual number ;
Tar, Set Git Count tre’ digits, i
Neioe Gnpurc)) _ net Cripat!'O)
wontle Teen Sebune 8"
@esti white 70!
: 1 1 27/10
Pe 7 tee Condama seodans 8
He i ; pie Count)”
rs) teverse : Dips [ge
Bos
bs tnt Cinpat ©) a Fen Zh ioee’
S=0, 7 Si Sh t8
while 9 70! “Onan oe
Opp. IB + int ($99
renghs P
GY) Quenber = tot input (“erker of “nunnber:"?)Unie number > 0+
digit = Number */ 10
aeversed..num = reversed - num D+ digit
number // +10
print ("Reversed number:”, ‘reversed n9o
Gy) Muu « ink input “Enter a nuraberi"?
Sut =
wahile number 71 + eke
sesult * ~ nun
NUM © =)
print (* factovial : $", result) y
W num int Cnput Center a numbe DH A
Ovi enum = nur rp
mum -dtgits «Jen Catr (nun) :
Sum - Of — powers +0 Sand Losodory
uohile num 70%
digit «num to. CO) suani
ett
num
Sum of — powers +. = agi
number // -19 . ,
thie Sum - Of" powers == oF; oun. @) doiey
Print (9 te ah “Airnetrong Number", o7i-num)
freaw Cline) Noy
Lohfle ur. powers, = Ov; -qurn; es
pene ("9t %& not an Romatong » "5 or
break
(nae