Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
100%
(1)
100% found this document useful (1 vote)
247 views
39 pages
Computer Class 12 Project
Computer class 12 all project
Uploaded by
kagini3173
AI-enhanced title
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
Download now
Download
Save Computer class 12 project For Later
Download
Save
Save Computer class 12 project For Later
100%
100% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
100%
(1)
100% found this document useful (1 vote)
247 views
39 pages
Computer Class 12 Project
Computer class 12 all project
Uploaded by
kagini3173
AI-enhanced title
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
Download now
Download
Save Computer class 12 project For Later
Carousel Previous
Carousel Next
Download
Save
Save Computer class 12 project For Later
100%
100% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 39
Search
Fullscreen
COMPUTER SCIENCE PRACTICAL EXERCISES 2022-23 CLASS — XII To write a menu driven Python Program to perform Arithmetic operations (+-*, /) based on the user's choice, SOURCE.CODE: print (i, Addition") [print ("2. Subtraction’ [print ("3. Multiplicatien") print (4. Division") Jopt=int(input ("Enter your choice:")) asint (input ("Enter the First Number: o=int (input ("Enter the Second Number if optesl: cmath print ("fhe Addition of two number 4 ear jelir opte=s: cratb print ("The Multiplication of two number is:",c) jolit optmma: if bead: print("Enter any other number other than 0") else: c=a/b print ("The Division of two number is:",c) elses print ("Invalid option") Result ‘Thus, the above Python program is executed successfully and the output is verified.SAMPLE OUTPUT: Python Program Executed Output: Bun=1: . Addditien + Subtraction - Multiplication Division inter your Enter the First Enter the Second Number: 23 mew The Addition of two number is: ‘RUN-2 1. Adddition 2. Subtraction 3. Multiplication 4. Division - Enter your choice:4 Enter the First Number: 6 Enter the Second Number:0 33 Enter any other number other than 0EX.NO:2 TING A PYTHON PRO‘ int (input ("How many Fibonacei numbers you want to display?")) © noc=0: print ("Please Enter Positive Integer") se: print (First) print (Second) for a in range(2,no): Third=First+Second First=Second Second=Third print (Third) Thus, the above Python program is executed successfully and the output is verified.How many Fibonacci numbers you want to display?8 DUWNHRO BUN-2; How many Fibonacci numbers you want to display?-5 Please Enter Positive Integer -DATE: CREATING A MENU DRIVEN PROGRAM TO FIND FACTORIAL AND SUM OF LIST OF NUMBERS USING FUNCTION, To write a menu driven Python Program to find Factorial and sum of list of numbers using function. SOURCE CODE; def Factorial (no) : Fel Af neco: print("Sorry, we cannot take Factorial for Negative number") elif nome0: print("the Factorial of 0 is 1") ae for i in range (1,no#1): Parti print ("The Factorial of",no, def Sum List(L): Sum for i in range(n): Sum=Sum+L [i] print ("The Sum of List is:",Sum) # Main Program print ("1. To Find Factorial") print ("2. To Find sum of List elements") opt=int input ("Enter your choice:")) Af opt==i: Sint (input("Enter a number to find Pactorial:"}) Factorial (n) elif optemz: (1 neint (input (“Enter how many elements you want to store in List?: for 4 in range(n): elesint (input ()) ‘L. append (ele) Sum_List (L) ‘Thus, the above Python program is executed successfully and the out1. To Find Factorial 2. To Find sum of List elements Enter your choice:1 Enter a number to find Factorial:5 The Factorial of 5 is: 120 - BUN=2: 1. To Find Factorial 2. To Find sum of List elements Enter your choice:2 Enter how many elements you want to store in List?:5 10 25 32 45 12 The Sum of List is: 124EX.NO: 4 DATE; CREATING A PYTHON PROGRAM TO IMPLEMENT MATHEMATICAL FUNCTIONS AIM: To write a Python program to implement python mathematical functions to find: (] To find Square of aNumber. fa] To find Log of a Number(ue. Logic) (@) To find Quad of a Number SOURCE CODE: impert math def Square (num) : S=math.pow (num, 2) return S$ def Log (num) : S=math.log10 (num) return S$ def Quad (X,Y): S=math. sqrt (K##2 + Y##2) return S jprint("The Square of a Number is:",Square(5)) [print("The Log of a Number is:",Log(10)) jprint("The Quad of a Number is:",Quad(5,2)) ‘Besult: ‘Thus, the above Python program is executed successfully and the output is verified.UTPUT: ited Pro; On The Square of a Number is: 25.0 The Log of a Number is: 1.0 ‘ The Quad of a Number is: 5,385164807134504EX.NO:5 DATE: CREATING A PYTHON PROGRAM TO GENERATE RANDOM NUMBER. BETWEEN 1 T0 6 To write a Python program to generate random number between 1 to 6 to simulate the dice, import random while True: Choice=input("\nDo you want to roll the dice(y/n):") no=random. randint (1,6) if Choicem='y': print ("\nYour Number is:",no) break Result: ‘Thus, the above Python program is executed successfully and the output is verified.SAMPLE OUTPUT: Python Executed Output Program: Do you want Your Number De you want Your Number Do you want Your Number Do you want to as: to to is: to roll the dice(y/n) :y 5 roll the dice(y/n) :y 2 roll the dice(y/n) :y 1 roll the dice(y/n) :nCREATING A PYTHON PROGRAM TO READ A TEXT FILE LINE BY LINE AND DISPLAY EACH WORD SEPARATED BY '#" ‘To write Python Program to Read a text file "Story.txt” line byline and display each word separated by “'. SOURCE CODE: f=open ("Story. txt", '5') Contents=£. readlines () for line in Contents: words=line.split() for i in words: print (i#'#!,end=' print ("") £.close() Result: i) ‘Thus, the above Python program is executed successfully and the output is verified.SAMPLE OUTPUT: a Joy on the heart of a sorrow. The sunset hangs on a cloud. ython Progeam Executed Output: Like# af Joy# ont thef# heart# off af sorrow. # The# sunset# hangs# on# a# cloud.#DATE: CREATING A PYTHON PROGRAM TO READ A TEXT FILE AND DISPLAY THE NUMBER OF VOWELS/CONSONANTS/LOWER CASE/ UPPER CASE CHARACTERS. AIM: To write a Python Program to read a text file "Story.txt” and displays the number of Vowels/ Consonants/ Lowercase / Uppercase /characters in the file. SOURCE CODE; feopen("Story. txt", 'r") Contents=. read () Vowels=0 ‘Consonants=0 for ch in Contents: if ch in ‘aeiouAkI60 Vowel s=Vowels+1 Af ch in 'bedfgh}kLanpqrs tvwxy2BCDPGHIRLMNPQRSTVWXYE” : Consonants=Consonants+1 Lf ch-dslower(): Lower_case=Lower_case+i 6 eh. dsupper(): Upper_case=Upper_ca: £.close() Print ("The total numbers Print ("The total number: »Consenants) print ("The total numbers of uppercase in the file:",Upper_case) Print("The total numbers of lowercase in the file:",Lewer_case} Result: ‘Thus, the above Python program is executed successfully and the output is verified.ome Canna ege NR lLike a Joy on the heart of a sorrow. ‘he sunset hangs on a cloud. Python Program Executed Output: |The total numbers of vowels in the file: 20 |The total numbers of consonants in the file: 29 the total nunbers of uppercase in the file: 3 the total numbers of lowercase in the file: 46CREATING A PYTHON PROGRAM TO COPY PARTICULAR LINES OF A TEXT FILE INTO.AN ANOTHER TEXT FILE AIM; To write a python program to read lines from a text file "Sample.txt" and copy those lines into another file which are starting with an alphabet'a' or'A’. SOURCE CODE: [Et=open ("Sample txt", "27 JF2=open ("New, txt", 'w') Junie ‘true: LinesF1readline() Af Line="'; break Sf Line [O}='9! o> Line[O}='A! = F2.write(Line) int (*AL1 lines which are starting with character 'a' or ‘A’ has heen copied successfully into New.txt") le1-clese() lz2.close() Result: ‘Thus the above Python program is executed successfully and the output is verified.n Executed am output: [Sample te - CUser/APPS/AppData/LocalPrograme/Python/Python6/Sample bt (35.8)* Fle Edit Format Alun Options Window Help [Aeroplane was invented by the Right Brothers. My favorite color is skyblue. [An apple a day keeps the doctor away. Python Executed Program Output; D> RESTART: C:\Users\A20$\AppData\Local \Prograns \Python\Sython36\PR COPY TEXT FILE. py All lines which are starting with character ‘a’ or 'A' has been copied successfully into New. txt} [a Newt - C\UuerAPPS\Appata\LocanProgramaPytnen\Aython3e\Newt (268)* File Ecit_ format Run Options Window Help ‘Aeroplane was invented by the Right Brothers. An apple a day keeps the doctor away.EX.NO:9 DATE: CREATING A PYTHON PROGRAM TO CREATE AND SEARCH RECORDS IN _ BINARY FILE AIM: To write a Python Program to Create a binary file with roll number and name. Search for a given roll number and display the name, if not found display appropriate message. ‘SOURCE CODE; import pickle def Create(): Feopen ("Students dat, ‘ab*) opt='y! while opte='y': Roll_Nosint(input ("Enter roll number: ')) Name=input ("Enter Name:") L=[Roll_No,Name] pickle.dump(L, 7) ept=input ("De you want to add another student detail (y/n) :") F.close() def Search(): Faopen ("Students .dat”,'rb'} nosint (input ("Enter Roll.No of student to search:")) found=0 try: while Trust ‘S~pickle-lead(F) Af S{0)=ano: print ("The searched Rell.Ne is found and Details are:",S) found=1 break except: F.close 4 found==0: Print ("The Searched Roll.No ts not found") fitain Program Create () Search () Result Thus, the above Python program is executed successfully and the output is verified.SAMPLE OUPUT: PYTHON PROGRAM EXECUTED OUTPUT: Enter roll number:1 Enter Name:aArun Do you want to add another Enter xoll number:2 Enter Name:Bala Do you want to add another Enter roll number:3 Enter Name:Charan : Do you want to add another Enter roll number:4 Enter Name:Dinesh Do you want to add another Enter roll number:5 Enter Name: Divya Do you want to add another student detail (y/n) :y student detail (y/n)‘y student detail(y/n):y student detail (y/n):y student detail (y/n) in Enter Roll.No of student to search:3 The searched Rell.No is found and Details are: (3, 'Charan'}DATE; (CREATING A PYTHON PROGRAM TO CREATE AND UPDATE/MODIFY RECORDS IN BINARY FILE To write a Python Program to Create a binary file with roll number, name, mark and update/modify the mark for a given roll number. SOURCE CODE; import pickle dof Create () : Peopen (“Marks.dat",‘ab') epts'y! while eptaety': Rell_No=int (input ('Enter coll number:')) Wame=input ("Enter ane: ") Markeint (input ("Enter Marks:")) ‘Le[Roll_No, Name Mark} pickle. dump (1,2) optsinput ("Do you want to add another student detail (y/n) :") F.close() def Updated): Paopen("marks.dat","rb+") Romint (input("Enter Student Roll Ne to modify mark: found=0 while True, PoseF. teli() Sapickle. 1oad(F) Lf 8(0}emno: PEInt ("The searched Roll.We 1s found and Details are:", 5) S{2]mint (Anpat ("Enter New Mark to be spdate:")) F.seek (Pos) pickle dump (5,2) founds F.seek(Pos) tmoving the file pointer again beginning of the current record Print ("Mark updated Successfully and Details are:",8) Break F.close(), A foundemo: Print (*The Searched Roll.Wo is not found") fMain Program Greate) Update 0 Results Thus, the above Python program is executed successfully and the output is verified.Enter Name:Arun Enter Marks:450 : a De you want te add another student detail (y/n) :y Enter roll number:2 Enter Name:Bala Enter Marks :342 De you want te add another student detail (y/n) ty Enter roll number:3 Enter Name:Charan Enter Marks :423 Do you want to add another student detail (y/n):y Enter roll number:4 Enter Name:Dinesh Enter Marks:356 - Do you want to add another student detail (y/n):y Enter roll numbe! Enter Name:Divya Enter Marks :476 Do you want to add another student detail(y/n) :n en No to modify marks:3 ‘The searched Roll.No is found and Details are: [3, ‘Charan’, 423] Enter New Mark to be update:470 Mark updated Successfully and Details are: [3, 'Charan', 470]EX.NO: 11. DATE; CREATING A PYTHON PROGRAM TO CREATE AND SEARCHI EMPLOYEE'S RECORD E To write a Python program Create a CSV file to store Empno, Name, Salary and search any Empno and display Name, Salary and if not found display appropriate IN CSV FILE. message. SOURCE COD! no=i: for Tapert env deft Create(): Feopen("Emp. csv"; ‘a' ,newLines'') Wecsv.writer (F) opt='y while optam'y': Nomint (input ("Enter Employee Nunbe: Name=input ("Enter Employee Name: Salefloat (input ("Enter Employee Salary: * 1=[No, Name, $31] W.writerow(t) optsinput ("De you want to continue (y/n)?:") Feopen("Emp.csv", ‘x! newline="\z\n") int (input ("Enter Employee number to search”)) found=0 rowncav. reader (P) data in row: Af data{0}=estr (no): print ("\nEmployse Deatils ar Print ('eeweeneenenereee" | ‘print (*Nama:",data(1]} print ("Salary ",data(2]) print ("seem found=t break Af found=—0; print(The searched Employee number is not found")| F.close() Main Program create () Search () Result; ‘Thus, the above Python program is executed successfully and the output is verified.SAMPLE OUTPUT: PYTHON PROGRAM EXECUTED OUTPUT: Enter Employee Number:1 Enter Employee Name:Anand Enter Employee Salary: 23000 Do you want to continue (y/n)?:y Enter Employee Number :2 Enter Employee Name:Akash P Salary:25000 De you want to continue (y/n) ?:y Enter Employee Number:3 Enter Employee Name:Balu Enter Employee Salary: 27000 De you want to continue (y/n) ? Enter Employee Number: 4 Enter Employee Name:Bavya Enter Employee Salary:29000 De yeu want te continue (y/n) Enter Employee Number:5 Enter Employee Name :Manej Salary: 35000 continue (y/n): y: Enter Employee number to search:3 Employee Deatils are: Name: Balu Salary: 27000.0To write a Python program to implement Stack using a list data-structure. SOURCE CODE: ot PUSH.) : Glemint (input ("Enter the element which you want to push:")) Stack. append (ele} det Popa: Ae Stack=={) print("Stack is Empty/Underflow"} else: PHint("The deleted element is:*,Staek.pop()) Get PRER() + topelen (Stack) =1 print ("The top most slomant of Stack is:",Stack[top]) dot Disp: topelen (stack) 1 print ("The Stack elomonts are:") for 4 in range-ttop,-1,- print (Stack{i}) fiain Program Stack=() opee'y while optmmy! peiaed print ("® print ("a print ("2 print ("3 print( print( ‘optmint (imput ("Enter your choice:")) £6 optmen: PUSH() LE optae2: POP() Lif optend: PEEK) lie optamt Dispaa print ("Invalid Input) ‘optminput ("De you Want to perform another stack operation ty/a) ?:") Result: Thus, the above Python program is executed successfully and the output is verified.s fen veevenveenwen Le PUSH 2. POR 3. PEEK 4. Display seaerenn eaten Enter your choic Enter the element which you want to push:10 Do you want to perform another stack operationty/n}? Stack Operations - ed baad ead eaa ee 1. PUSH 2. POR 3. PEEK 4. Display fhtiee nee tentee Enter your choie Enter the element which you want to push:20 Do you want to perform another stack operation(y/n)? Stack Operations 1, PUSH 2, POR 3. PEEK 4. Display Enter your choice:1 Enter the element which you want to push:30 Do you want to perform another stack operation(y/n)? Stack Operations aeeaaenanes Serene 1. PUSH 2. POR 3. PEEK 4. Display soeenannesaaes. Enter your choice ‘The Stack elements are: 30 20 10 Do you want to perform another stack operationty/n} *:y Stack Operations setreaeessteneee L. PUSH 2. pop 3. PEEK 4. Display saseeeteeseeneee “Enter your choice:3 The top most element of Stack is: 30 Do you want to perform another stack operation(y/n)?:yStack Operations Wena henaawenan ae 2. PUSH 2. por 3. PEEK 4. Display tteatranatenanee Enter your choice:? ‘The deleted element is: 30 Bo you want te perform another stack operation ty/n)? Stack Operations — steastanarenaeee 1, BUSH 2. POP 3. PEEK 4. Display hneneananananan Entex your choice:4 Do you want to perform another stack operation (y/n)7inEX.NO: 13 DATI (CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON (GNSERTING RECORDS AND DISPLAYING RECORDS) To write a Python Program to integrate MYSQL with Python by inserting records to Emp table and display the records. SOURCE CODE: TopeT wysal connector [con=mysql. connector. connect (hest=' localhost! ,username= ‘root’ ,password="root' ,database=' employees SF con.is_connected() : eurmeas. cursor () opty while opten'y's Mowint (inpur(“Enter Eaployes usbers*)} Manewinpat (“Entar Exployes Nime:") Gendarsinput (Enter Employee wader (4/7) "> Salarynint (input ("Enter Exployee Salary:")} Quory="INSERE 20 EXP VALUES({) "(2 ,'()' 11)" Foxmat Qe Mane, Gonder, Sadaey) cur-execute (Query) an-comm’t.0 PEIN ("Record Stored Successfully") eptminput("Do you want to add another employee detaile(y/n) louery=" SELECT + PROM EMPT; Jcur-execute (query) ldatascur.fetchall () for 4 in datas print (4) Jeon clone th Result: Thus, the above Python program is executed successfully and the output is verified.SAMPLE OUTPUT: Python Executed Program Output; Enter Employee Number:1 Enter Employee Name: Arun Enter Employee Gender (M/F) :M Enter Employee Salary: 20000 Record Stored Successfully Do you want to add another employee Enter Employee Number :2 Enter Employee Name: Bala Enter Employee Gender (M/F) iM Enter Employee Salary: 25000 Record Stored Successfully Do you want to add another employee Enter Employee Number:3 Enter Employee Name:Bavya Enter Employee Gender (M/F) :F Enter Employee Salary:27000 Record Stored Successfully Do you want to add another employee Enter Employee Number: 4 Enter Employee Name:Saravanan Enter Employee Gender (M/F) :M Enter Employee Salary:29000 Record Stored Successfully Do you want to add another employee (1, 'Arun', 'M', 20000) (2, 'Bala', 'M', 25000) (3, ‘'Bavya', , 27000) (4, ‘Saravanan', 'M', 29000) details (y/n) vy details(y/n) cy details (y/n) iy details(y/n) :nEX.NO: 14 DATE: (CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON (SEARCHING AND DISPLAYING RECORDS), To write a Python Program to integrate MYSQL with Python to search an Employee using EMPID and display the record if present in already existing table EMP, if not display the appropriate message, SOURCE CODE: [import mysql connector lcon-nysql.connactor connect (host=' localhost! ,username='root! if eon, is_ connected () : eur=con.cursar() Print (useeeeeseneeeeeennery print("ilelcane to Employee Search Screen") Print ("teens ereeeeenrseeeeeres rere’) Nomine (input ("Enter the employes number to s6ach:")) Query="SELECT * PROM EMP WHERE EMPID=(}".format (No) cur. execute (Query) datascur fetchone () Lf datatmtione: print (data) word='rest!' ,database=' onployses')} seeesseeer) else: print ("Record not Found! 11") lcon.close(? Result: ‘Thus, the above Python program is executed successfully and the output is verified.SAMPLE OUTPUT: Python Executed Program Output: BUN JERE OH nn nba kao bie Welcome to Employee Search Screen JHE ETS nn eri Ria A Eni Enter the employee number to search:2 (2, 'Bala', 'M', 25000) Run - 2: ete tt et ettcreticteteteetecicaters Welcome to Employee Search Screen JIS ISI IARI OIA I IIIS III IA IIIA Enter the employee number to search:505 Record not Found!!!EXNO:15 DATE: (CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON {UPDATING RECORDS) AIM: To write a Python Program to integrate MYSQL with Python to search an Employee using EMPID and update the Salary of an employee if present in already existing table EMP, if not display the appropriate message, SOURCE CODE: jimport myagl.connector con=mysql.connector connect (host=" localhost” -usernane='root ' ,paseword='soot’ ,database='omployoos') Lf eon. is_connected() + eurmooh cursor () Print (tebbassaeaeeassassececubaasssssenuaaascany Print (Welcome to Employes detail update Screen") print (tabhessiseshasepescesensaasaan ses: ) Nowint Ginput ("Enter the employee number to Update:")) Query="SELECT * FROM EMP WHERE EMPID=()~.format (Wo) ‘eur. execute (Query) datamcur.fetehone() (ef datatations: print ("Racord found datatls print (data) answinput ("Do you want to update the Salary of the above employee (y/nl?:") Sf anges'y! or angee New_Salsint (input ("Enter the Wow Salary of an Bmployee:")) QIS"UPDATE EMP SET SALARY=() WHERE EMPID=(}" format (New_Sal Wo) cur -execute (01) eon, commit () Print ("EEployea Salary Updated Suecessfully") (Q2e°SELECT * FROM EM" eur execute (02) data-cur.fetchalL() for 4 in data: print (4) else: print ("Record not Found! tt") ‘Result: Thus, the above Python program is executed successfully and the output is verified,Eqployee detail update screen Enter the eaployee number to searcl Record found details are (3, *BAVER", *F*, 27000) Do you want to update the Salary of the above employes (y/n) 2y Enter the New Salary of an Employee:30000 Employee Salary Updated Successfully G, ‘rant, '™°, 20000) (2, "Bala*, "M', 25000) (3. Bavea’ 30000) (4. ‘Saravanan’, “M', 23000) ‘Bun-2: Cetretertte teat reeetett reer terrerecnsd Welcome to Employee detail update Screen HAAAAH ER EANRA RRA Le aR ee Enter the employes number to Update:500 Record not Found!!1 SOL OUTPUT:‘SQL COMMANDS EXERCISE - 1 Ex.No: 16 AIM: To write Queries for the following Questions based on the given table: DOA | Fees 1997-01-10 | 120 1998-03-24 | 200 1996-12-12 | 300 1999-07-01 | 400 1997-09-05 | 250 1997-06-27 | 300 (COMPUTER | 1997-02-25 | 210 | 23 [NULL 1997-07-31 | 200 | oleae = Usha | (a) Write a Query to Create a new database in the name of "STUDENTS" Sokmysql> CREATE DATABASE STUDENTS; (6) Write a Query to Open the database "STUDENTS" Sol:mysql> USE STUDENTS; {c) Write a Query to create the above table called: Info mysql> CREATE TABLE STU(Rollno int Primary key,Name varehar(10},Gender varehar(3), ‘Age int,Dept varchar(15),DOA date,Fees int); (d) Write a Query to list all the existing database names. Sal: mysql> SHOW DATABASES; Output;{e) Write a Query to List all the tables that exists in the current database. Sol: mysql> SHOW TABLES; (8) Write a Query to insert all the rows of above table into Info table. Sol; INSERT INTO STU VALUES (1,"Arun’,"M’, 24,'COMPUTER','1997-01-10', 120); INSERT INTO STU VALUES (2,"Ankit','M’, 21,'HISTORY’,'1998-03-24", 200), INSERT INTO STU VALUES (3,"Anu’, 20, 'HINDI','1996-12-12', 300); INSERT INTO STU VALUES (4,"Bala’,"M’, 19, NULL,'1999-07-01', 400); INSERT INTO STU VALUES (5,Charan'M, 18,HINDI,'1997-06-27", 250); INSERT INTO STU VALUES (6;Deepa’,F’, 19, HISTORY''1897-06-27", 300); INSERT INTO STU VALUES (7,Dinesh’,'M', 22,"COMPUTER’; 1997-02-25", 210} INSERT INTO STU VALUES (8,Usha',F’, 23, NULL,'1997-07-31', 200); {g) Write a Query to display all the details of the Employees from the above table ‘STU’. Sols mysql> SELECT * FROM STU; (h) Write a query to Rollno, Name and Department of the students from STU table. Sol: mysql> SELECT ROLLNO,NAME,DEPT FROM STU;SQL COMMANDS EXERCISE ~ 2 23 {a) Write a Query to select distinct Department from STU table Sol: mysql> SELECT DISTICT(DEPT) FROM STU; (6) To show ail information about students of History department Sol: mysql>SELECT * FROM STU WHERE DEPT="HISTORY’; (c) Write a Query to list name of female students in Hindi Department, mysql> SELECT NAME FROM STU WHERE DEPT='HINDI’ AND GENDER=F; Output:(d) Weite a Query to list name of the students whose ages are between 18 to 20. {e) Write a Query to display the name of the students whose name is starting with ‘A’ Sol: mysql> SELECT NAME FROM STU WHERE NAME LIKE ‘A%'; Output: Write a query to list the names of those students whose name have second alphabet 'n' in their query ip names Sol: mysql> SELECT NAME FROM STU WHERE NAME LIKE '_N9%';SQL COMMANDS EXERCISE - 3 DATE: AIM: To write Queries for the following Questions based on the given table: [ Age | Dept | DOA = i M 24 | COMPUTER | 1557-01-10 | 120 2 M 21 | HIsTorY | 1998-03-24 | 200 3 F_ | 20 300 4 M ig 400 5 Me 18 250_| 6 F 19 | HISTORY 300 F M 22 | COMPUTER 210 8 F 23 [NULL 200 {a) Write a Query to delete the details of Roll aumber is 8. Sol: mysql> DELETE FROM STU WHERE ROLLNO=8; Output (After Deletion): {b) Write a Query to change the fess of Student to 170 whose Rell number is 1, if the existing fess is less than 130. Sol: mysql> UPDATE STU SET FEES=170 WHERE ROLLNO=1 AND FEES<130; Qutput(After Update](ce) Write a Query to add a new column Area of type varchar in table STU. Sol: mysql> ALTER TABLE STU ADD AREA VARCHAR(20); {d) Write a Query to Display Name of all students whose Area Contains NULL. Sol: mysql> SELECT NAME FROM STU WHERE AREA IS NULL; Output: (e) Write a Query to delete Area Column from the table STU: Sol: mysql> ALTER TABLE. STU DROP AREA; (i) Write a Query to delete table from Database mysql> DROP TABLE STU;Ex.No: 19 SQL COMMANDS EXERCISE - 4 DATE: AIM: To write Queries for the following Questions based on the given table: TABLE: STOCK ——Phame | Deode| Qty _| Unitprice Date | Ball point pen 102 [100 [10 2021-03-31 Gel pen premium [102 [150 [15 [2021-01-01 cil y _a: 6 3 [102 [6015 a | [10s [ iso [s BOoeO1-15 ‘TABLE: DEALERS. Daame {a) To display the total Unit price of all the products whose Deode as 102. mysql> SELECT SUM(UNITPRICE) FROM STOCK GROUP BY DCODE HAVING DCODE=102; Output; (b) To display details of all products in the stock: table in descending order of Stock date. Sok ‘mysql> SELECT * FROM STOCK ORDER BY STOCKDATE DESC; Output:(e) To display maximum unit price of products for each dealer individually as per deode from the table Stock. mysql> SELECT DCODE,MAX[UNITPRICE) FROM STOCK GROUP B¥ DCODE; Output: (d) To display the Pname and Dname from table stock and dealers. mysql> SELECT PNAME,DNAME FROM STOCK 8,DEALERS D WHERE 9.DCODE=D.DCODE; Output:
You might also like
Hangman
PDF
No ratings yet
Hangman
14 pages
Address Book Management System
PDF
No ratings yet
Address Book Management System
18 pages
Student Management System
PDF
No ratings yet
Student Management System
11 pages
Studen Record System Project Report
PDF
0% (1)
Studen Record System Project Report
17 pages
Hangman Project PDF
PDF
No ratings yet
Hangman Project PDF
17 pages
Food Booking System
PDF
No ratings yet
Food Booking System
26 pages
LAB PROGRAMS With Screen Shot
PDF
No ratings yet
LAB PROGRAMS With Screen Shot
31 pages
Summer Training Report
PDF
No ratings yet
Summer Training Report
16 pages
Java Notes
PDF
No ratings yet
Java Notes
121 pages
Cs File
PDF
No ratings yet
Cs File
103 pages
Student management system
PDF
No ratings yet
Student management system
41 pages
Project Report On Employee Management System
PDF
No ratings yet
Project Report On Employee Management System
20 pages
INternship Report
PDF
No ratings yet
INternship Report
22 pages
Student Management System Menu Driven Project
PDF
100% (1)
Student Management System Menu Driven Project
26 pages
Scripting Language Lab Report
PDF
No ratings yet
Scripting Language Lab Report
27 pages
Cgpa Calculator1
PDF
No ratings yet
Cgpa Calculator1
20 pages
Hostel Management System Hostel Management System
PDF
No ratings yet
Hostel Management System Hostel Management System
12 pages
Student Information Management System Project Report II
PDF
No ratings yet
Student Information Management System Project Report II
63 pages
School Management: A Project Report On
PDF
No ratings yet
School Management: A Project Report On
20 pages
FInal Project Report
PDF
No ratings yet
FInal Project Report
27 pages
College Management System Project Report
PDF
No ratings yet
College Management System Project Report
30 pages
Problem Solving With C - UE20CS151 Lecture Notes: Department of Computer Science and Engineering
PDF
No ratings yet
Problem Solving With C - UE20CS151 Lecture Notes: Department of Computer Science and Engineering
52 pages
Faculty Management Final Report
PDF
100% (2)
Faculty Management Final Report
44 pages
DBMS Project Report - $#$&
PDF
100% (1)
DBMS Project Report - $#$&
22 pages
Fantasy Cricket Game Using Python
PDF
No ratings yet
Fantasy Cricket Game Using Python
18 pages
Cs Project 2019
PDF
100% (1)
Cs Project 2019
24 pages
Project File Student Management System
PDF
No ratings yet
Project File Student Management System
14 pages
Concert Management
PDF
No ratings yet
Concert Management
20 pages
DBMS Lab activities
PDF
No ratings yet
DBMS Lab activities
21 pages
Flight FRNT Bca
PDF
No ratings yet
Flight FRNT Bca
62 pages
SRM Mess Management System
PDF
No ratings yet
SRM Mess Management System
18 pages
E Authentication Project Document
PDF
No ratings yet
E Authentication Project Document
76 pages
Face Recognition Based Attendance System
PDF
No ratings yet
Face Recognition Based Attendance System
70 pages
Online Grading System 6 PDF
PDF
100% (1)
Online Grading System 6 PDF
48 pages
Scholarship Management System: Team Members: BM10518, BM10527, BM10545 Class: II-MCA
PDF
No ratings yet
Scholarship Management System: Team Members: BM10518, BM10527, BM10545 Class: II-MCA
29 pages
A Modular Approach To Program Organization
PDF
No ratings yet
A Modular Approach To Program Organization
51 pages
Fantasy Cricket Game Using Python Report (20BCS1062)
PDF
100% (1)
Fantasy Cricket Game Using Python Report (20BCS1062)
35 pages
Project On School Management System
PDF
No ratings yet
Project On School Management System
31 pages
Hostel Management
PDF
No ratings yet
Hostel Management
20 pages
AWP Practical 2-1
PDF
0% (1)
AWP Practical 2-1
15 pages
Birthday Party - Basics of Operators & Basic Programming Practice Problems - HackerEarth
PDF
80% (5)
Birthday Party - Basics of Operators & Basic Programming Practice Problems - HackerEarth
4 pages
Python Report PDF
PDF
No ratings yet
Python Report PDF
41 pages
Q1.) Write A Program To Implement Simple Arithmetic Calculator. Perform Appropriate Validations Program Code
PDF
No ratings yet
Q1.) Write A Program To Implement Simple Arithmetic Calculator. Perform Appropriate Validations Program Code
3 pages
Project
PDF
No ratings yet
Project
12 pages
Group Members: Hasnain Ahmed Abbasi (2012216) Danish Ahmed (2012209) Bilal Atiq (2012237)
PDF
No ratings yet
Group Members: Hasnain Ahmed Abbasi (2012216) Danish Ahmed (2012209) Bilal Atiq (2012237)
4 pages
Student Management Project Report Tkinter Mysql
PDF
No ratings yet
Student Management Project Report Tkinter Mysql
31 pages
Final Mini Project
PDF
No ratings yet
Final Mini Project
50 pages
School System File
PDF
No ratings yet
School System File
58 pages
Project 25 CGPA Calculator
PDF
No ratings yet
Project 25 CGPA Calculator
16 pages
Class 11 IP Project Python SQL
PDF
No ratings yet
Class 11 IP Project Python SQL
3 pages
List of Practicals of XII Computer Science 083 Practical Files 2022 23
PDF
No ratings yet
List of Practicals of XII Computer Science 083 Practical Files 2022 23
5 pages
Hotel Management System: Project Synopsis
PDF
No ratings yet
Hotel Management System: Project Synopsis
25 pages
Practical-4:Implementation and Time Analysis of Factorial Program Using Iterative and Recursive Method
PDF
No ratings yet
Practical-4:Implementation and Time Analysis of Factorial Program Using Iterative and Recursive Method
5 pages
Project - Report
PDF
No ratings yet
Project - Report
56 pages
Sales Management System Report File - 4
PDF
No ratings yet
Sales Management System Report File - 4
23 pages
Python P
PDF
100% (1)
Python P
11 pages
Hangman Game
PDF
No ratings yet
Hangman Game
15 pages
Project Report ON Library Management System
PDF
No ratings yet
Project Report ON Library Management System
5 pages
Practical Record Cbse 2023-2024
PDF
No ratings yet
Practical Record Cbse 2023-2024
38 pages
Download
PDF
No ratings yet
Download
46 pages
Answer
PDF
No ratings yet
Answer
41 pages
Phpro 2
PDF
No ratings yet
Phpro 2
17 pages
Phy Pro
PDF
No ratings yet
Phy Pro
18 pages
Test Organic Chemistry (25!11!2023)
PDF
No ratings yet
Test Organic Chemistry (25!11!2023)
17 pages