Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
129 views
Computer Class 12 Project
Computer class 12 all project
Uploaded by
kagini3173
AI-enhanced title
Copyright
© © All Rights Reserved
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
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
129 views
Computer Class 12 Project
Computer class 12 all project
Uploaded by
kagini3173
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Computer class 12 project For Later
Carousel Previous
Carousel Next
Save
Save Computer class 12 project For Later
0%
0% 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
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6128)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brene Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (933)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8215)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2923)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4972)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Toibin
3.5/5 (2061)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1987)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2641)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2543)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
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
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Principles: Life and Work
From Everand
Principles: Life and Work
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Steve Jobs
From Everand
Steve Jobs
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Yes Please
From Everand
Yes Please
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
The Outsider: A Novel
From Everand
The Outsider: A Novel
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
John Adams
From Everand
John Adams
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
Answer
PDF
Answer
Phpro 2
PDF
Phpro 2
Phy Pro
PDF
Phy Pro
Test Organic Chemistry (25!11!2023)
PDF
Test Organic Chemistry (25!11!2023)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
Little Women
From Everand
Little Women
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel