0% found this document useful (0 votes)
0 views

Cs Record Python

The document contains a series of programming experiments aimed at implementing basic arithmetic operations, checking for Armstrong numbers, and manipulating lists. Each experiment includes an aim, program code, and output results, demonstrating successful execution. The programs utilize various functions to perform tasks such as addition, subtraction, and file handling.

Uploaded by

avengerdeepak12
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Cs Record Python

The document contains a series of programming experiments aimed at implementing basic arithmetic operations, checking for Armstrong numbers, and manipulating lists. Each experiment includes an aim, program code, and output results, demonstrating successful execution. The programs utilize various functions to perform tasks such as addition, subtraction, and file handling.

Uploaded by

avengerdeepak12
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Expt.No.

Page No.
Date

AIM
CA psqaam to Implinent auithmetíc alalala
sng Bundina
PROGRAM
de add Ca b):
Stin a +h
de sub (ab):
otisn a-b
dq mul (a,b):
ouu a h
dey div (a,b):
oln alb
del
olunn alb
de mod (a, bi

de tapla,b
a

#main

a = fntCngt(' enten fist nunben )


b= int (inpt enten
gersnd hwmben: )

cp : input ( Enten an gpenaler


Expt. No.
Page No.
Date :

to
pxint (add Ca )
eli op = : :
prnt (sub (a, b))

pint (mul (a, b))


psint Coliv(a, b)

print (ely la b))

psint (mod (a, b))

paint (exp la,b)


Ase
psint inyalid cpenatan )
y" else "N":
C= input (^ To Cootioue_poss
i4 co lowen () !=y'
pint ('hank you
byeak
OUTPUT
pumben: 1
tnten ist 1
nte seLond numben

Enten an oaoaten :

Continue pess "y', else"N": Y


To
nten fo&st umben :4
Enten Aecend
inten an opraten

To Continue presy" ese"N":Y


Enten Boit number 4
nten seond nwm bey i A
enten Operalon :
8
To Continue pessy" elke "N": y
Enten first numben 8
Entes second numben : 6
inten

To (ontnue pes y", else "N":N


1hank You
Expt. No. Page No.
Date :

AIM
to chak whethen a

numben is Axmstrong OY

PROGRAM

de, asmsBeng (num:

Aum 1 Bum 1 +(ans* ans*a)


fnt [num ho)
otunAum 1

man

(Toputaten a numben : )
|Dum = fnt
Numben )
puat wm,is an amsaong
CUkmylson DumbenJ
pnt (num,'i ot a

RESULT Aucceshully
The
OUTANT

inten a numben 1
1 an armstong numben

Enten a numben : i53


I53 s n amsong numben
tnten a numben: S5
55 ot an
rot
aumsreng
m`beg umben
Expt.No. Page No.
Date:

AIM
dalned undion to Qcept a t and
hall the Numbeny. and dauble the odd numhery

ROGRAM

de Aunll):

pxunt ('updated t:' L)

aun

|2==fat (input( Eaten the no of list elements z )

V: îat (oput ('enten the lit ee ment )


leapend (
prunt ( dit sacieveda

RESDLT
The psogaam i ex lded Buceslully
OUTPUT

Entes the elemet,


tnten the element : 1
Enten the plernent : a
Enten the list Dlament : 3
Enten element : 4
tnter the liut clement : 5
Lot soieved : L1, 2, B, 4, 51
updated at:a, L.0, 6,2.0, 10]
Expt No. Page No.
Date

AM
C
dolined undkia to CDat the
numbenA and odd Dmbend

PROKRAM

de funcl):
Aor in tange (o let )
even Cont t 1

Oddcount t= 1
caunt:oddiouat,nevenowt ;' eeniuot)
punt ('odd

man

)
no o element
k: fnt (inpt( Eaten the
(Enten lement'))
V fnt (inpt
a. apped()
put ist ecied:a

RESULT exewtel Aucenhully


Jhe pueen
TCP
OuTPUT

element : 4
Enten the no. o!
énten ?lement : 1
tntes tlement : &
En ten flement 3
inter Element : 4
Iist sucieved : 1,2, 3, 4
even ount a
Page No.

AIM
usite INDEXLIST (L), uhon L
clsments passd the Auntion the
list amed indoz ta
lit that
yaluvns anothen
Flemerts
Atures the indias ob

PROGRAM

ipdez_lst=]
fox i in stange lo, anl2)):
index list. append [I
psat indax likt: inde-lit)

maun

k= fn (input ('Eaten the n0


ox ? în gang (): ))
V: at input (' Eaten elemest;

puot ( Dit eieed :,a)

RESULT
Ihe paoqiam exeutal Aucesf uly

TC
OUTPUT

Enten the o ol elemeny :5


Enten elemert : 1
Enten element
element : 9
ntes element
inten element :4
Enten element 5
liut ie yed : L1,2, 3, 4,51
indem Ist 0, , 2, 3,4]
AIM
pagilam to HOad toat filemyie tzt
and
al dáplay the numbe
diqid in the frle
ROGRAM

de, shaw():
( open Cmyfile tat')
data = suado

low = O
digit = o
Vaulat : 'A','E'ol
in data :

in Vowlist :
Vowels t 1
else:

p+=1
ple :
low t= 1

if Lsdigit02
ExptNo Page No.
Date

pkunt CNumben o Vouelh : Vouel)


pint (Numben o (ononent:ons)
phunt C'Numben uepenCaxi )
Phunt('Numbe) ohlouen co: low)

fedsel)

Ahaw)

RESULT
Jhe caeuted AUces<ully
day then uno agaun lome
way go ain Rain
.tzt bile My
iodigit Number
Numben
Cas
a uppen
Numben
|7lonsonent Number
d
16Vowels
i Numben
buTPUT
Page No.
Ext Nc.

Date

AM
toead a ttat 7ile sample. tat and
Cunt and cluplay the Nunben
COunt to epuated)
be

PROGRAM

de Count AJ )
uib open sample tzt) as li

Lount A, lount I =O,0

i line ol.ppen):='A':
lountA += 1
phnt (line. AbRip O)
eli ine lo1.uppn() =='I':
(punt. T t=1

olmo (ontA_, loust T)

ount AI:Count_A-TO
Jinea Atasbing uib A
:lountAI O1)
lountAT [11)

RESULT
The
OuTAUT

No. o res stoing with A: 1


Nor lirs ul I:1

sample.txt
AI Tndians my byothad and sistery
1 love my lounty
AIM the that
to tomove
Waite
and
lwih ?t to
ontans the chaacten'a' in aa file
anothen 7ile

PROGRAM
del apydata()i
Bi openlCSounetzt)
B2 openlC destinationht',u')
data = k oadliaa ()
Lox line ia data i
A'not in lne anda' not in lne :
6

l2 seeklo)
data 2 l2 aadlo)
psint (data2)
fl. close)
l2.close)

main
Copydota

RESULT
Jhe pHogram AKçasfully
OUTPUT
Hello wosld
thes 8 python

Sona t t
Hello world
Thu Python
a
pogramming Larngoge
AlM by Ine and duplay each
Read a textile ne.
wod sepexated by- a

PROaRAM

R= cpeolmyfile tat)

Wordy = isplit)
Box a în word:
print (a44)
lclose

RESULT
The pqaam is ereutalAUCCesluly
OUT PUT

hello +
world #
Py thon #

myßie.tzt
hello world python
Page No.
Date

AIM
a bioasy tle uitth
uih name aund Qmben

kox a qfven4dl. nwmber and dsplay the name


fox
nt kound diplay
diuplay appsapiate masage
PROGIRAM

inpaxt ptckle
le ogen (Binazy fle.dat 'wb+)
de, Înput data)i

while
: fntlinput ('Eaten the
name : input(Eaten the name:)
mek = int (input ('nten the mask : )
Lst. append ([vno, namemank)
înpt ( To ontinue pss Y elseN0

pickle dump (Ist, )


f-flush
del seanch data ()2
foseek lo)
faund fase
nO = int(inputEnten oll n0 : ")
While Tue :
ty 3
lead(g)
data = pickle,
Expt.No.
Page No.
Date.

except i
break

fox io data

Aaund
punt ('Rollng fauad=ol,'name- uc l,nak
Hec27)
break

psint (Budent not found)

foclael)

nputdota ()
eand data)
OUTPUT

Enten Roll n0 1
Enten Name
Enten maks 500
To Continve , poes y, else N : N
Enten Holl 0: 1
Roll no. found 1 Name XYz Masks = S00
Expt No. Page No.
Date:

AIM
a to update Stulent Aorend

stored binasy-file binay fale edat', and di play


sppncpaiate message ot fousd.
ROGRAM

Tmpozt pr<kle.
de date Hucend ():
Cile open(' binasyfle.dat' 'xb+)
fntinput( Enten ol) o o student to be pdated: )
wbile Tue i

data = pickle . laad (Rile)

bseak
kox ? in rang (lonl dota):
mak = fnt (iaput (Centen the mask to uplate :'))
data[ 2 mank
pant CoLerd updeted')
break

piat ('Roll no ot faund)


{ile Aeek o)
pikle. dump ( data, fie)
file seek (o)
st piikk. laadllile)
lex s in st
TCP
OUTPUT

foten toll no. o Btudent to be updated : 11


Enten the mak to update : 494
tecerd updated
Dame =) XYz moes ) 499

inten noll ono Shudent to be updoted : 2


no. not
found
toll no 1 name ’ Y z
maks 444

You might also like