0% found this document useful (0 votes)
17 views16 pages

Cs Program

Uploaded by

komalkavya1446
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
17 views16 pages

Cs Program

Uploaded by

komalkavya1446
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 16
Eaeetss #Program to make functions to find the number of uppercase letters, lowercase letters string passed as an argument to these functions. def noofupper(nd) countup=0 a) Tete) ones ON Meee Ce mee} Come) Comat: au! Coens countup+=1 PT eee Cee) Coder ie a} Comte a ee) Cornet OM eam) Rese ca) Pea) Peete) noofdigits(n) rhe 1) Enter a string: "mY Name is mOHIn SOOD AND | am 17 YEArs old No. of uppercase letters are: 16 ements eee} Oem Ltd INV ea uC CoP Soa} PROGRAM-2 Sa Ce ae CU a en eC aa Coc tS ecru enema teal from random import randrange CR anes) a=randrange(m.n.s) eric) aes meint(input(Enter an integer: ')) nzint(input(‘Enter an integer: ‘)) s=int(input("Enter an integer’) for i in range(6) random(m,n,s) print(1) OUTPUT:- Oem UNC rae a1) erm UN ee SU es RZ) IVA se CoN iW Noob (n-) PROGRAM-3 ae eC keg ce Se ee wer ame ies eta Cnr aea aga def double(list 1) for iin range(len(list)) errs eel ere ny list2=eval(input("Enter a list of numbers:")) double(list2) print(list2) Cove Leta ee) [10, 4, 6, 18] NAME: KOMAL KAVYA Wee Es) PROGRAM-7 ae UO EO Ae eS Ce Ro te Me RE a te oes hua eum Re een nae eM Cis at) Pome lists. split() ae} print('words beginning with an uppercase letter") ae TORU cg eet print(,end="S") ces continue CaS or H PU att) FILE:tfile.txt Seg InN) eon] con aUs Reem Re ae ee ed Sse SES eae as Teen ues Peed NAME: KOMAL KAVYA, recom Tn) rogram to create a copy of text file ‘Old.bt’ by changing all instances of digits with a “sig in the new file named as "Now:txt" eae ne aa) Poet eat Tew) oe i print() tle.close() eee ue ese) Pee) hfile.close() aeons Mohin scored 106 in maths out 150 so very well ean ne Mohin scored ### in maths aut #it# so very well MAU: Mohin scored ### in maths out ##t# so very well NA Sao AAA roe TE} PROGRAM-6 eC oa Ce ee ee Le Cosette eeu Eman ten) ee ee) Be Pro) cates) shecount.0 Pace) an at hecount+=1 eee os shecount+=1 print(No. of occurences of he in the sentence is:-hecount) print(No. of occurences of she in the sentence is-shecount) aed oct he is a good student but he does not know how to behave, but she is a good girl fore POC etn ee Coe Nee Reece eect aed Pee cies NAME:- KOMAL KAVYA Wen) PROGRAM-7 CUR ae ee MU rc ny the name of the text file and passes it as an argument to Carey Cones} ee enc PS oec Coe) anes anus ete rate Crates PC eR ee ceo) ioe Gee ae) filevowels(file12) ea eae he is a good student but gets distracted easily lO teas eae Su react Sane ee oe DAV oa COZ (WN) PROGRAM-8 #Program to create a binary file named ‘student.dat' containing (rolino, name, marks) and write a function search() to search for a rollno in the file and display the details. Call the function in ei Ent a rere fees esgo tne on) Pog Dae mo=input("Enter roll number: ") Pee aera te) Goes a ee) oS ea Oe ae) Pete ce) Ee en Mere MR Cue TCD) UT wore) def search(tollno): file=open("Student.dat" rb’) OY Ou as ree=pickle load{fle) ever PN ee) bio Coa PaO MRD) Cece) INAV cel VEL CANN fone} PROGRAW-9 a om eS ee ae a ce) Cera ed 7 marks from the file. Coe oy Cerner or ieee aa (input("Enter the rollne: ")) Pom G am e eg) RQ GsT mote es) eens pickle.dump(list1,file1) PUR ea file close() Ceres Peer eae ea) Wr while True: p=pickle.load(file1) ey print(‘students who have scored 90 above marks are’,p[1]) Cre es appendrecord) See) eves preg ed Sr eee et Cee tg eae Een et ae) eee Cease eae ee een eR RCE eR Cot Saag ae Ieee eet eee aaa eee Se ee eee ee eae ae ae Enter 1 to continue and 2 to exit : 2 Students who have scored 90 above marks are : Yoru NAME: KOMAL KAVYA CLASS: XII-B PROGRAM # Program to read the file “Empl.csv’ and creates another file "newemp.csv" with the delimiter eee Uae es aac a ooo CR} Ca file=open("Emples" "w",newline") eae a oa) a.writerow((Employee 1D’, Employee Nume., ‘Designation’. "Salary’)) fori in range(3) empid=input("Enter Employee ID: ") Roe Sac asc) Cee ance saree Se ese sa odor ne) emplrec.append({empi.name.desig.sal]) Pert) CT) Cie eee si ea file2=open("newempl.csv’,w’.newline=" ey print("Output:") for jin a print) file.close() eras es eS rem n uaao reas Sees Lege Suc Enter Employee Salary: 25000 rmsd eZ) remeron ee iny remnant ad eran EN) Cu o.oo remsn oon cacy rem en OCe ee egeea eran er Nee) Employee ID’, ‘Employee Name’, ‘Designation’, ‘Salary’ iercr eee omc ct meg prec OD [oe ae se | Output ene Ron ee ame) Tee PCL uD (pte UL emp oe EN Cire) ug ever Man Ul Reo sv.reader(file2) Texel eRe eS Man Re aS Pena ae cs Ove cd an eet) eed eee eed eae PONS ert CCNY arcane Ce Cn ae) Enter Item Price: 50 Do you wish to continue entering data(y/n): n eee Teaco MC ea eo ee Ee eeceet TOU TMC Ue Mea NAME:- KOMAL KAVYA CLASS:- XII-B PROGRAM-11 # Program to create a file named ‘Item.dat’ having the following dictionary as a record Un nC te eC Men eee Ne eee Son import pickle def create() file open("item.dat", wb’) Eines Rue itemid=input("Enter Item ID: ") Teen Gta no) recat Gs ear) ema CRE Cn MC Ce Meee} Bene Maran) ans=input("Do you wish to continue entering data(y/n): ") file.close() Penne file=open("Item.dat’,'rb') ny CRTs r=pickle.load(file) print("Records are: ") print(r) Cert se ste file.close() create() display() eae) DON eae eR uN ar sae kee OE Pm Ma led Sree nce PTR Sa) Do you wish to continue entering data(yin): n Enter rolino to be searched : 2 ee a ea na 2) Enter roll number: 12 ere aa) eg Le) PNRM Ra Rn cum RO mee Seay Enter marks: 78 PNRM Ru cum 0a rege eRe eet eM ag

You might also like