You are on page 1of 37
ma a GQGOO QVAVAVAVAGAVA Computer Science (Python) GAVAVAGOVA 9] | 9} 9] ke) 5 te) | B 5 ma PAGAGAGOGAGA EI Use EE EEE EEE EEE Name of Practical Sign of the Teacher WAP to compute xn of given two integers x and n. WAP for calculating simple interest. WAP to accept a number from the user and display whether it is an even number or odd number. WAP to accept percentage of a student and display its grade accordingly. WP to print Fibonacci series up to certain limit. WAP to display prime numbers up to a certain limit. P to accept a number, find and display whether it’s a Armstrong number or not. WAP to accept a number and find out whether itis a perfect number or not. WAP to print the sum of the series 1+x1/1!+x2/2!+.......X4/(n)!- exponential series. WAP to print the following pattern 1 12 123 WAP to accepta string and display whether it isa palindrome. WAP that counts the number of alphabets and digits, uppercase letters, lowercase letter, spaces and other characters in the string entered. WAP to accept a string (a sentence) and returns a string having first letter of each word in capital letter. g p J Q g p QJ Q g Q Q Q g Q g p QJ Q g Q QJ Q g Q g p J 5 g 9} QJ Q a Q QJ Q a p g Q g p g Q g Q g Q g Q a p g Q g p WAP to remove all odd numbers from the given 1G OYAGAIAGAIIIATGIAGNIAGIITAIAIIGAGIIAGIIIODIIGITAGATIVAGAGAIAGAIAGOGAGAG 1G 9G9GHGHGHGHGHGHGHGHGOGHGOGHGOHGHGHGHGOGOGOGOGOSG: USE EEE EEE EEE EEE list. WAP to display second largest element of a given list. WAP to display cumulative elements of a given list. WAP to display frequencies of all the elements of alist. WAP in Python to display those strings which are string with ‘A’ of given list. WAP in Python to find and display the sum of all the values which are ending with 3 froma list. WAP to shift the negative number to left and the positive numbers to right. WAP to swap the content with next value divisible by 7. WAP to accept values from user and create a tuple. Write a program to input total number of sections and stream name in 11" class and display all information on the output screen. Write a Python program to input names of ‘n’ countries and_ their capital and currency, store it ina dictionary and display in tabular form. Also search and display for a particular country. SOL 25 Queries g p J Q g p QJ Q g Q Q Q g Q g p QJ Q g Q QJ Q g Q g p J 5 g 9} QJ Q a Q QJ Q a p g Q g p g a g Q g Q g Q a p g Q g p g A q p g 1FOYAGAIAOAGIYAGGIAGOIAIIIAIAIIGAGIIAGIIIODIIGITAGATIVAGAGDIASAIAGOGAGAG 1G 9G9GHGHGHGHGHGHGHGHGOGHGOGHGOHGHGHGHGOGOGOGOGOSG: EK a Ea Code: [& pgrm_O.py - C/chapter 3/pgrm_0.py (3.6.5) File Edt Formet Run Options Window Help ‘int (input ("Enter a number" nt (input ("Enter power") ) z=(x**n) print (z) seo Output of the program*™**#*** TB Pion 365 sa =a Fle £4 Shal_Dehug Options Window ‘Hap python 2.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (mate 1)} on win32 ‘Type "copyright", "credits" or "license()" for more information. RESTART: C:/chapter 3/pgrm_0.py enter a number? Enter power3 QVAVAVAVAGAVA GAVAVAGOVA 5 | 3 5 | 5 | | H 3 ma PAGAGAGOGAGA EI ma a Sa SEES [8 *pram.toy-C\chapter3\prqm_tpy B65)" File Ede Format fun Options Window Helo print ("SIMPLE INTEREST CALCULATION\n" print ("Enter the following details.") p =int(input ("aAmount: ")) =int( input ("No. of Years: ")) int (input ("Rate of Interest: ")) = (p*nér) / 100 print ("\n The interest is : "+ str(i)) Lag CokO +055555*Qutput of the program***=##** “Ya Pron 39 Shei, eT oul i Fie Edit She Debug Ope Python 3.6.5 (v3.6.51£59c0932b4, Mar 28 2018, 16 207:46) [MSc v.1900 32 bit (inte1)] on win3a Type "copyright", “credite" or "license()" for m ore information, - s hapter a\pra mi.py -= TMPLE INTEREST CALCULATION nter the following details. amount? 10000 No. of Years: 2 Rate of Interes the intere 3 + 2000.0 EES QVAVAVAVAGAVA GAVAVAGOVA ER EE ER ECE ma PAGAGAGOGAGA EI EK a Ea 7h pgrm_6.py - C\chapter3\pgm_ Spy File Edit Format Run Options Windows Hel |k - int (input ("enter no: if (%2==0): print ("Even number") els print ("Odd number" +5 Output of the program***#*#* 7 Pons x Fite Shall Osbig Optone Windows Hap python 2.7.4 (default, apr 6 2013, 19:54:46) [MSc v.1500 32 bit (Inte = 1)) on win32 Type "copyright", "credits" or "license()" for more information. RESTART =a nese QVAVAVAVAGAVA GAVAVAGOVA ER EE ER ECE ma PAGAGAGOGAGA EI EK a Ea Code: "LB rom 7oy-cithepe Spon 7py 385) ~~ 1 [Fle Eat Fomst fun Optons Window Hee A prgroam to accept percentage of a student and display grade perc = float (input ("enter percentage of a student : ")) # statement perc > 85: condition! rint ('A') if pere >70 and perc <=85: dition2 print ("B") elif pere > 60 ahd perce <=70: condition3 print ('c') elif pere >45 and pere < onditiond int (*D") print ("=") =3=55-Qutput of the program™™*** Grenier ‘le fit Ste Ong Oper Wadey Hep python 3,6.5 (v3.6.5:£59c09%2b4, Mar 26 2018, 16:07:46) [msc v.1900 32 bit (In tel) on wing2 Type "copyright", "credits" or “License()" for move information. RESTART: C:\chapter 3\prom_7.py iter percentage of a student ; 78 in Gans ESSE QVAVAVAVAGAVA GAVAVAGOVA 5 | 3 5 | 5 | | H 3 ma PAGAGAGOGAGA EI Code: [& fibo.py - G/chapter 3/fibo.py (3.6.5) File Edit Format Run Options Window Help i = int(input ("enter the limit") print ("Fibonacci series\n") print (x,y,end while (z<=i) print ( z, end x=y yr xty + Qutput of the program* 55 La Python 3.65 shell o x File fit She Debug Optone Window Help Python 3.6.5 (v3.6,5:£59c0932b4, Mar 28 2018, 16:07:46) (MSC v.190 * 0 32 bit (Intel)] on win32 Type "copyright", "credits" or "license ()" for more information. RESTART: C:/chapter 3/fibo.py enter the limit30 Fibonacci series 56.13 21 | Ln:5 Cova G9 GOGHGHGHGHGHGHGHGHGOGHGOGHGOGHGOGHGOGHGOGOGOGO' EK a Ea SEDEEES Code: [& prime_range.py - C:/chapter 3/prime_range.py (3.65) File Edt Format Run Options Window Help x=int (input ("Enter limit” for num in range (x+1): i while ieee5959'Output of the program" [Be Python 385 Sha file Edt Shell Debug Options Window Help ox Type “copyright”, “credits” or “license()” for moze inform ~ ation. RESTART: C:/chapter 3/prime_range.py Enter limit30 is a prime number is a prime number is a prime number is a prime number is a prime number is a prime number is a prime number is a prime number is a prime number is a prime number is a prime number is a prime number ESSE QVAVAVAVAGAVA GAVAVAGOVA ER EE ER ECE ma PAGAGAGOGAGA EI Code: LB axmstrongpy - C/chapter3/practcalfle/nmstrongpy 65) File Edit Formet Run Options Window Help num=int (input ("enter 3 digit number")) f = num sum = 0 while (f>0): a £810 = int (£/10) sum = sumt+(a**3) if (sum==num) : print ("it is a Armstrong no",num) else: print ("it is not a armstrong no",num) \ ¥ inst? Coho EW EE EE EC EE EEE EOE >eee959'Output of the programe" [Been =o x Fle Edt Shall Debug Options Window Help [python 3.6.5 (v3.€.5:£59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Inte D1 on winsz |Fype “copyrignt*, "credits" or "License()" for more information. RESTART: Ct/chapter 3/practical file/armstrona.py enter 3 digit number371 it is a armstrong no 371 Q g Q g p J 5 g 5 QJ Q a Q QJ Q a p g Q g o a 9 g Q a Q g Q a 5 g Q g Q g 5 q Q g o 4 Q a 5 J p B G9 GOGHGHEHGHGHGHGHGHGOGHGOGHGOHGHGHGHGOGHGOGOGOGO! Code: [B pertect.py - C/chapter 3/perfect.py (3.6.5) File Exit Format Fun Options Window Help i il 5 =0 num= int (input ("enter number") ) while i [@ Python 36.5 shell ao x | File Edit Shell Debug Options Window Help _ Python 3.6.5 (v3.6. 59c0932b4, Mar 28 2018, 16:07: % 46) [Msc v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> RESTART: C:/chapter 3/perfect “py enter number6é it is a perfect no. >>> | G9 GOGHGHEHGHGHGHGHGHGOGHGOGHGOHGHGHGHGOGHGOGOGOGO! EK a Ea Code: ‘7h mathserespy-C:/chapter 3/mathseriespy File Edit Format Run Options Windows Help x =float (input (‘enter value of x y=int (input ("enter limit')) s =0 for i in range(0,n+1): fact=1 for k in range(1,i+1): fact=fate*k s+=(-x**1)/fact (i) Beir (s) >eeee555' Output of the programe" [a Python 38.5 Shel a x Fie E6t Shell Oebug Options Window Helo Python 3.6.5 (v3.6.5:£59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win3z Type "copyright", "credits" or "license()" for more information. RESTART: C:\chapter 3\mathseries.py enter value of x:2 enter Limite 7.387301507301587 >>| EES QVAVAVAVAGAVA GAVAVAGOVA 5 | 3 5 | 5 | | H 3 ma PAGAGAGOGAGA EI Code: [& pattern.py - C:/chapter 3/pattern.py (3.6.5) — a x File Edt Format Run Options Window Help i whil j while j< print (j,en j= jt print () i=in EW EE EE EC EE EEE EOE Output of the program* oo 1 12 1 2 o. Q g Q g p J 5 g 5 QJ Q a Q QJ Q a p g Q g o a 9 g Q a Q g Q a 5 g Q g Q g 5 q Q g o 4 Q a 5 J p B G9 GOGHGHEHGHGHGHGHGHGOGHGOGHGOHGHGHGHGOGHGOGOGOGO! Program 11; WAP to accept string and display whether itis a palindrome. Code: (3 palinpy- C/chapteripatiny 65) Fie Esit Format Run Ontions Window Help str=input ("Enter the string") en (str) pel-l inde: while (index>'Output of the program" [2 Panenasssnes = Fle fat Set oebug options Winsor 86 Python 3.6.5 (v3.6.5:159c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Int JeL)] on win32 ‘Type "copyright", "credits" or "License(|" for more information. a = RESTART: Ci/chapter’ 4/pallin.py ringNITIN a Palindrome G9 GOGHGHGHGHGHGHGHGHGOGHGOGHGOGHGOGHGOGHGOGOGOGO' SEES ma a Sa ec a ne QVAVAVAVAGAVA see BM asewere SE anon seGisitos chi isspace Os GAVAVAGOVA a digitat,n 5 id 3 5 | 8 | g H 3 ma PAGAGAGOGAGA EI ESSE Code: L& “prgm_4.py - C:/chapter 4/prgm_4.py (3.6.5) File Edit Format Run Options Window Help stri=input ("enter a string:”) Eo print ("original strng",str1) str2= x% = strl.split( for a in x str2 += a.capitalize()+" " print (str2) GOVAGVAGAVAS oa | re 9g Output of the program* 555% [B Python 3.55 shet File Edit Shel Debug Options Window Help Python 3.6.5 (v3.6.5:£59c0932b4, Mar 20 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or “license()" for more informati on. >>> aus ram 9GVAVAGVAGAVAGA COC RESTART: C:/chapter 4/prgm_4.py = ma enter a string:we are learning python original strng we are learning python We Are Learning Python >>> | Lné Coke a ISSA @O9GOGOGOGOGOGOGE le] EK a Ea e prom 2py-Cichapeer Siprgm 2/865) =| File Est Format fun Optione Window Help ai | f main() L=[2,7,12,5, 10,15, 23) for i in L if is L. remove (i) print (b) main() I ¥*5 Output of the program*™ss55 ie python 3.6.5 (v3.6.5:£59c0932b4, Mar 28 2018, 16:07:46) 0 32 bit (Intel)] on win32 RESTART: C:/chapter 5/prom_2-py INS v.190 Type "copyright", "credits" or "license()" for more information. QVAVAVAVAGAVA GAVAVAGOVA 5 | 3 5 | 5 | | H 3 ma PAGAGAGOGAGA EI Code: (ib cetonustergecepy > cvenapters meeconaige, = File Edit’ Format Run Options Window Help L=[41, 6, 9,13, 4,23] m=max (L) secmax=L[0] for i in range(1,len(L)): if L[i]>secmax and L[i] Ti Phan 365 Se =— ox File Ed Shel Orig Options Window Hep _ python 3.6.5 (v3.6.5:f59c093264, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Inte A 1)1 on win32 ‘Type "copyright", "credits" or "license()" for more information. RESTART: C:/chapter 5 lists/ELE_START_A.py AUSHIM AKHTAR AMAR Lappearing 3 times QVAVAVAVAGAVA GAVAVAGOVA ER EE ER ECE ma PAGAGAGOGAGA EI EK a Ea Code: (3 SUM_LAST3.py- Cuchapter 5 lsts/SUM,LAST3.py (3.63) File Edt Format Run Options Window Help L=[33, 13, 92,99, 3,12] sum=0 x=len(L) for i in range(0,x): if type (L[il int: if L[i]%10==3: sum+=L [il print (sum) i Output of the program* ss Ta Paton 36550 =o x python 3.6.5 (v3.6.5:£59c0932b4, Mar 2€ 2018, 16:07:46) IMSC v.1900 32 bit (Inte * 1)] on win3z Type “copyright", "credits" or "license()" for more information. RESTART: C:/chapter 5 lists/suM_LAST3.py RESTART: C:/chapter 5 lists/SUM_LAST3.py QVAVAVAVAGAVA GAVAVAGOVA 5 | 3 5 | 5 | | H 3 ma PAGAGAGOGAGA EI EK a Ea SEDEEES Code: LB swap negetiveoy - Di/new sultan/unit 1/cd/practicals/chapter 5 lsts/swap_neg.. File_Fdit_Fornat Run Options Window Help I-Ie, Aly “Ass “8, Bh =; Sy. 3S, SST n=len(1) print ("original list:",1) for i in range(n-1): j in range (n-i-1): if LEj1<0: 1191,115+11=115+11,111 print ("After shifting list is: “,1) »eee779'Output of the program Fie EMR Shell Debug Optene Window Help = ee ree ee Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Inte + 1)1 on win32 ‘type "copyright", "credits" or “License()" for more information. RESTART: D:/new sultan/unit 1/cd/practicals/chapter 5 lists/swap_negetive.py original list: [-12, 11, -13, -5, & -7, 5, -3, ~6] ee eC Ea yee ed ae ae Ay et te Gee QVAVAVAVAGAVA GAVAVAGOVA 5 | 3 5 | 5 | | H 3 ma PAGAGAGOGAGA EI EK a Ea SEDEEES Code: | swap_diisble 7 py “D/nel sultniinit Led/pecialchap ee ei Fie Edit Format Run Options Window Help Jnum=[3, 21, 5, 6, 14, 8, 14, 3] Len (num) | posed if num[i]%7==0: num[iJ, num[i+1]= num[it+i], num[i] i=i+2 print (num) «+0444 Qutput of the program**4#+* [a Phen 385 she File_Eat_Shel_Debuy Options _Wodow Hep python 3.6.5 (v3.6.5:£59c09392b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit ( > Intel) ] on win32 ‘Type “copyright”, "credits" or “license()" for more information. RESTART: D:/new sultan/unit 1/cd/practicals/chapter 5 lists/swap_divisible_ T.By 13, 5, 21, 6, 8 14, 3, 14 >>> | ESSE QVAVAVAVAGAVA GAVAVAGOVA 5 | 3 5 | 5 | | H 3 ma PAGAGAGOGAGA EI EK a Ea a creat tuple py - Di/new sultar/unit1/cd/practcals/Chapte 6/creattup.. File Edit Format Run Options Window |Help t=tuple () nt (input ("Enter any number: ")) i in range (n) a=input ("Enter Number: #4 Qutput of the program*o* Posy Eas [Hie Eat Shat_osbug Gptons Window Hep Python 3.6.5 (v3.6.5:59¢0932b4, Mar 26 2018, 16:07:46) [MSC v.1900 42 bit (Inte -| 2)1 on win32 Type “copyright”, “credits” or “license()" for more information, RESTART: D:/new sultan/unit 1/cd/practicals/chapter 6/creat_tuple.py Enter any number: 5 enter Enter enter enter Enter output is ESSE QVAVAVAVAGAVA GAVAVAGOVA ER EE ER ECE ma PAGAGAGOGAGA EI a=input ("Enter section: ") nput ("Enter stream name: classxi[a]=b print ("Class") "\t"," on", '\t', "Stream name") for i in classxi: print ("X1",'\t',i,"\t',classxi[i]) +++" Output of the program******** [aPitensa5 St Fle ESt Shel uy Optons Window Help 1)1 on win32 ‘Type “copyright”, “credits” or “license()" for more information. RESTART: D:/new sultan/unit 1/cd/practicals/chapter 6/create_dict.py total number of section in xi class: 4 Section: XI A stream name: SCIENCE Section: XI B stream name: COMMERCE section: xI c stream name: HUMANITIES Section: XI D stream nama: FASHION STUDIES section Stream name XE A SCIENCE XIB COMMERCE XIC BUMANITIES XID FASHION STUDIES Python 2.6.5 (v2.€.5:f59c0932b4, Mar 28 2012, 16:07:46) [MSC v.1900 32 bit (Tate + io cons 'OG9G9G0GO 39896980G9G0G0506 BEDI iO AVAIAVOVAGOVAGA AGAVAVAGAVA. EK a Ea File Edit Format Run Options Window Help disdict () n=int (input ("Bnter number of entries") while icon: c=input ("Enter Country:") cap=input ("Enter Capital:") curr=input ("Enter currency of country:") dl [c]=(cap, curr) i = it al. keys () tt ("\nCountry\t\t", "capital\t\t", "currency") iin i: z= d1fil print ("\n',i,"\t\t',end for j in z print (j,'\t\t!,end: | # seaching | x=input ("\nEnter ntry to be searche for i in 1 print ("\nCountry\t\t", "Capital\t\t", "Currency\t\t alfa] rint ("\n',i,'\t\t',end="") jin print (j,"\t\t',end="\t\et") 5 tea? Coto. QVAVAVAVAGAVA GAVAVAGOVA ER EE ER ECE ma PAGAGAGOGAGA EI «480*Qutput of the program***###** Enter number of entries3 Enter Country:Austia Enter Capital:vienna Enter currency of country:Euro Enter Country:India Enter Capital:Delhi Enter currency of country:Rupee Enter Country:France Enter Capital:Paris Enter currency of country:Euro EW EE EE EC EE EEE EOE Country Capital Currency Austria Vienna Euro India New Delhi Indian Rupee France Paris Euro Enter Country to be searched: India Country Capital Currency India New Delhi Indian Rupee Q g Q g p J 5 g 5 QJ Q a Q QJ Q a p g Q g o a 9 g Q a Q g Q a 5 g Q g Q g 5 q Q g o 4 Q a 5 J p B G9 GOGHGHEHGHGHGHGOGHGOGHGOGHGOHGHGHGHGOGHGOGOGOGO' 2. Command for using the database. ree DET ca) gl ee eT Pret etcel oe eee nn ae rs cores rire ooy Query OK, @ vous affected (8.05 sec) One eee) od seers Per eee USTs Wea CC RCCL PR Me aOR RE] Cries ete es Cee reba eee REC Co RC Cie CA Ot eS CLES SECM ETT) Ce ae ieee CeCe) Sear SCeCSe aL ees ere SCRE ein c it aero) Try eC core aor Carin eed eres eee Tae eee Uae eS Ciao ec Ad Arey CeCe Reger ror freicre eae ere) Been eres Peotone Se ee pvtty ere eae ee see CRY em 4 Pa eet mee eet) eee ra re ee Reet rae SCC eas Cgc ees TERE CE a OSES Maer seer Pd lauz Kha Rey i ceCre ear anes cae) ere using HAVING clause. eee ee eR using Group by with order by. See test ent en tse Pe ya nagpal ea apc i ee 20. Command for equi-join of tables. Portes 4 ce Cero Pcrratss Pa Ry set (A.88 see) 22, Command for_using group by clause in join. ree earn ery 23, Command for using group by and order by clause in equi-joi 24. Command for using where clause and group by. EGG hear es Dee eec Meese) DURE CR Ce eee ey COSI ates rare Cees) ete Se Me TSEC es eee) 28. Command to increase marks. EW EE EE EC EE EEE EOE Peo ar makin) POS ae orc ees) ere a ore mC art cea 30. Command to a delete table. Wena ees CS GR oer eed Q g Q g p J 5 g 5 QJ Q a Q QJ Q a p g Q g o a 9 g Q a Q g Q a 5 g Q g Q g 5 q p g o 4 Q a 5 J p B G9 GOGHGHEHGHGHGHGHGHGOGHGOGHGOHGHGHGHGOGHGOGOGOGO!

You might also like