Python Programs

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Page No

Date

write oa paoqTam to Say hello to qiyen nams


Code Om=inpa ("Eater Name"

Entes Name Parxa

Q2cite a pmogocam to porint oskil value o


qiN encharacten

Code c= input ("Eater a charactex")


Point The ASCTI value od ord Cc)
Enter charachex- H
The ASCTT value of His 4

03arite a poro qntam take a integers forom


USer and perfox m Nariou arithmatic aberaton
On tahle

Code Q= intinpa Enlex 1st nunber"


haint (inpat(Calor D.nd ounbes)
add=atb Print ("hddiion , add)
Painte" sSubstra dion" Ssb)
Paint Cnmwtiplicatisn="m
div alb Porint Division=diu)
4orite
QthutiEotes
Code C- orite Code
Ocatput trangle a
ParintAeao Gubpat
be
heAloat(inpat a
a bb
PrintPaint
Ca=a)
Float prora asintprogram
b.zint
Cinpah
baue9.5
Nalue
Entex Entexbe linpuCinpuh
Enter Numho
Cotea
9ndEaten o
Nuobea
to addBo
to
CEote"Eoter Swap
value calcalate be5 ("Entex
"Entex
3.15 saue value
alue
od
heigh o a as")b
ane
height")
haje b7 a5 ot Date PageNo.
ot tuoio
tuo
taiangle
2.5 inteqer
xhex
()) a!valuehexaclecima poindC
) paint(
ca)) act ood
yaluec"actol point
bin() Valueso Bioars Point
C
Cy) Paint
11
acoCx)) Punckian Pacaes paint
"y: Paint XEX ('pin
3
a)) Nalol
ue) Albiolate Paint(
(la"a Prrint
alo3
math Jnpont
Cocle
funchion Building 97
bil) bilL Total Paint
("
dis bill- bill
dis=Cbillo)/l00
atebill=unit
) unit
elecaiciky p(GinpatC"Cnter
eraate
("Enter (iUnik-float
npatntefloat
Code
Unitg. 9iven bilfon
icit calate Cal progam
to awrite
Date
ioPage
Date

Bding funcion 2
Code:mpÑnt math

Point(aa)

Bilding Puncion 2
Code import math

paint Seuareroot ot math Sar!r


point ("faptarialo 3 math.Pacezialr
baint Mio.no.io Ao,2o,30,4oso
paint min Cio, Qo,9o 40,50)
prin(marnoin
pri nt Chas(max lo,2o,30,4o5o
(lo,2obob Tol
Page No

Date

O8onite a poqram to perfonm variou operation


in lis

List denna
list1 L 2 3 1
point Clisk )
list a-l:0, Jessa31
point Clist o)

paint clist 3)
my_ lish*lo, 20,fessa12.50Emma'
poin mylis)

paiot (my. list )


paint (mslisC41)
nint CmyligEI7)
haint (my i t 7 )
paint ( mylist 47
Page No.
Date

99
List demo 9
liste llo, 26,'Sessa l2.50,Emma25,5o
y
paint Cmy list Ce :5])
mylist -l5,9 Tor7.50 Emma
pqint Cmylist 41
hay lis CS g.'Torm 7.50 Emma
on item is mylist
boint Citem)
mylisE = CS8,Tom7:50
ylis append 'Emmo
Dorint Cmylist)
mslistappend 95,50,7S
Lpaint Cmy ist)

Lst demo 3
my list S8, Tom7:so
insert my liskinsent t Cas,so,75])
Pege No
Date

Listdemo 3
my liste5,3Tonm50
mylis,insert (2,25)
pintCmylist)
inser ioo m listioserf (3,(25,50,75))
point(mylist)
m i g 2 , h 6 8 , lo l 2T
1ist Co] =2o
pointCmyist)

mad mylist CI3 7:[40, 6o, 80


paintCmulist)

mylist lisC[a, S, R,lo 2 )


emoVe mysoemoe C6)
emoVe nLisemoye CR)
Page No.
Date

piat qreater
qxeateN nnbe
pogram to
o tuonumbe
ain(input("Lnte 0:
Code
b=int inpat C Enten b ) )
PCa>b):
paintCais qeaten")
el Se
pint Cbis qt eat en )

ICote a pragrarm to chesk i numbes is


DosHve , neq aive
a-int Cinpa CCotexe a "
Paint(a is positive")
eliCa=z0)
point Camber is zero'")
else
paint (" numbex is negaive")

To check the NumbeA is even ar odd


Code

aint CioputCEoter a
S eNn
elSe
Print (a is odd")
Pege No.

Date

Raint CinpatCLCntera)

p a i n t a s even")
else
Paint Ca iS odd)

Q13 Cuite a mro oro to cheak if a string


Cont enoCerteen choyacter
Code -
Sta l= nput f" Entes charact e
char l input ("Eatex any Characte)
paint C"The Staing tonian character ")
else
parint The slaingq not contain chaather)

Qla tonite a prosam ot qiven 6 ha Using while

Code tohile
numint inptat ("Entea anumhexc:")
paint squane
) end Ci, paint
nos od 3o o Paint Code
fop') Cuse" Zo4to
numbex mogamfor
odc Q1oitea
mu
1
Do m
1Ktohile
no)) cEntex
nintinpt lo:
Cade
Dumbes
given
pint pragam
to QlCcorite
l) CSumof paint
)c=Cinpat"Eates int -no
mbeg
) ("Eater
nosintCinpet
n Code
Code
totalO Aumbex
o
calceate
he to P15crite
a
Date
No. Pege
Pege No
Date

curm b er homto qiven numbex


Code endno.s int Cinpust CEnterastnuA

QLScoite a proqrom to cclelale Sum of all


number ho m to qiven numb -ex
Code
end no= int Cinpat C"Enten lastnunbex
SumO
fox no ismange CL, end oot):

OLq oalte a progran to mint Pollaoing patton


Using
2

4
12
Code
Tange CL,G)

paint4 end
Page No
Date

Onitea proqpoms to print tollooin.


patenn æsing o lop

S 3 2

Code

nange Coos,o-D:
CosioTange
pointCiendl
")

proocm to print paime


Dumber

Code

NUm, "is not a Pmme humber...

bredk

Pacint (num"a number is Prine


Page No
Date

CcOaile a pogson o pag Staterment


22
Code
foxLe Lher in pythan
Pass
prinhisis pag bloc'
paint 'current lette': letk e
pointGeoad byel

23 rite Q proqrcum tó check enterNean

Code
Leapyege
Year = L0t npat Cente vear -
if C year )or Cyear 400)D:
paintCYear i8 leap year
else
point yearis not leap year-)

aut put
Potec year
2o24
2024year geap yer
Page No
Date

Topn U s e r Can vote o not bae


entered age
Code

aqe int CinpaE ("ente age=)


ages Lahile Cage 9)
vote)
paint C" youCan
Lele
point Coccannot v o t e )

p5orite proam to inte


even Do

from
Code
Paint(" 1 to 1oo even numberi"
fox
Dato

Pathon
to Say hello to
Lonteo progann oÐP tochech iEa SixiagCant en
qLuen name acertaincharaot er
asci Volueof
wAP to prin giueh WAP to qiven chaacter iSvoLe cono
charaot e AP Square ot qisen S nog Using ahle
twointegeg fom USen
wAP ak Q93Colcalae the eum o nwm user enter
and perform Uariaus amith mahoo ero tota=0
operadan wPPTLo paint if can vote gr nok
s
multiplicaan table
9 valued ot inte6 P loy odd no beto lto3o
coAP to colcclate ol torong le @
2coAP to paint ned diuisible by ejthe
elecoici between |tosa
Buildin9 Lunctian ) o loo
Building Puncion Q23 AP to pint N 2onakral numbee
cwAP to perform varias) aperathis
-Qlo is- dema ohileo
to aisen number
oAP to Porint qrreates nmber a to print patesn
3

Numbe
WAP o check numbeis potie
OegHue Zere 4S
gISocheUk Yhe Numis add en even g32 p to p i t ntteD
wAP lae among three nmbe
epl4 To chesk nter Near Dal
To che ck qiuen nunhes iSepos
i poime qum
to prio yeSa
On
hebase cupon giuen manks
Poo No
Dato

33 to prin
wmte a progremto prinhSum
digit otgiuen num bex
di splay numbe 5o toUsing bal.
aik a progra lon Pibonaca Serie
6 Conile a proqcam Facoxia give
31ite a poro gram te eperce int
no

e a pro gcam te pintpine


9 demo Set method
Tunle method demo
0nike a praqram to demo dictana

You might also like