Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
24 views

Practical File

The document provides detailed instructions for students on how to format their practical programming assignments, including writing programs and outputs on separate pages, using specific writing tools, and maintaining a practical file. It includes a series of programming tasks in Python and SQL, with sample code and expected outputs for each task, covering topics such as file handling, data structures, and basic algorithms. The document emphasizes the importance of organization and clarity in presenting programming work.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Practical File

The document provides detailed instructions for students on how to format their practical programming assignments, including writing programs and outputs on separate pages, using specific writing tools, and maintaining a practical file. It includes a series of programming tasks in Python and SQL, with sample code and expected outputs for each task, covering topics such as file handling, data structures, and basic algorithms. The document emphasizes the importance of organization and clarity in presenting programming work.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Instructions to Students:

1. Write each program on new page with blue pen.


2. Write Program Number on top of each page & underline it.
3. Write output of Python programs on first blank page of each program.
4. The output of SQL queries should be written after each answer on the same
page.
5. Fill the index of practical file with complete practical question.
6. Cover your practical file with brown paper.

Program 1

Q. Read a text file line by line and display each word separated by a #.

1
Ans.
f=open("story.txt","w")
s=input("enter a story:")
f.write(s)
f.close( )
f=open("story.txt","r")
doc=f.readlines( )
for i in doc:
words=i.split( )
for a in words:
print(a,end="#")
f.close( )

Output:
enter a story:I study in APS CT
I#study#in#APS#CT#

Program 2

Q. Read a text file and display the number of vowels/ consonants/uppercase/


lowercase characters in the file.

2
Ans.
f=open("PARA.txt","w")
s=input("Enter a para:")
f.write(s)
f.close( )
f=open("PARA.txt","r")
f1=f.read()
v,c,u,l=0,0,0,0
for ch in f1:
if ch in 'aeiouAEIOU':
v+=1
if ch not in 'aeiouAEIOU':
c+=1
if ch.isupper( ):
u+=1
if ch.islower( ):
l+=1
print("No. of vowels",v)
print("No. of consonants",c)
print("No. of uppercase characters",u)
print("No. of lowercase characters",l)
f.close( )

Output:
Enter a para:IstudyinAPSCT
No. of vowels 4
No. of consonants 9
No. of uppercase characters 6
No. of lowercase characters 7

Program 3

Q. Create a binary file with name and roll number. Search for a given roll number
and display the name, if not found display appropriate message.

3
Ans.

import pickle
import sys
dict={}
def write():
f=open("student.dat","ab") # a-append, b-binary
n=int(input("Enter no. of students"))
for i in range(n):
print("Enter student",i+1,"details")
dict["roll"]=int(input("Enter the rollno"))
dict["name"]=input("enter the name")
pickle.dump(dict,f) # dump- to write in student file
f.close()

def search():
f=open("student.dat","rb") # r-read, b-binary
r=int(input("enter the rollno to search"))
found=0
try:
while True:
data=pickle.load(f) # load-reads from file
if data["roll"]==r:
print(data)
found=1
break
except EOFError:
pass
if found==0:
print("record not found")
f.close()

while True:
print("MENU\n 1-Write in file\n 2-Search\n 3-Exit")
ch=int(input("Enter your choice"))
if ch==1:
write()
if ch==2:
search()
if ch==3:
4
sys.exit()

Output:

MENU
1-Write in file
2-Search
3-Exit
Enter your choice1
Enter no. of students2
Enter student 1 details
Enter the rollno1
enter the nameAjay
Enter student 2 details
Enter the rollno2
enter the nameAnil
MENU
1-Write in file
2-Search
3-Exit
Enter your choice2
enter the rollno to search1
{'roll': 1, 'name': 'Ajay'}
MENU
1-Write in file
2-Search
3-Exit
Enter your choice3

Program 4
Q. Create a binary file with roll number, name and marks. Input a roll number and
update the marks.
Ans.
import pickle
student=[]
5
f=open('student.dat','wb')
ans='y'
while ans.lower()=='y':
roll=int(input("Enter Roll Number:"))
name=input("Enter Name:")
marks=int(input("Enter Marks:"))
student.append([roll,name,marks])
ans=input("Add More?(Y)")
pickle.dump(student,f)
f.close()
f=open('student.dat','rb+')
student=[]
while True:
try:
student=pickle.load(f)
except EOFError:
break
ans='y'
while ans.lower()=='y':
found=False
r=int(input("Enter Roll number to update:"))
for s in student:
if s[0]==r:
print("Name is:",s[1])
print("Current Marks is:",s[2])
m=int(input("Enter new marks:"))
print("Record Updated")
found=True
break
if not found:
print("Roll number not found")
ans=input("update more?(Y):")
f.close()
Output:

Enter Roll Number:1


Enter Name:Ajay
Enter Marks:60
Add More?(Y)Y
Enter Roll Number:2
6
Enter Name:Vijay
Enter Marks:70
Add More?(Y)n
Enter Roll number to update:1
Name is: Ajay
Current Marks is: 60
Enter new marks:80
Record Updated
update more?(Y):n

Program 5

Q. Remove all the lines that contain the character `a' in a file and write it to another
file.

Ans.
7
f=open("first.txt","w")
f.write("a quick brown fox\n")
f.write("one two three four\n")
f.write("five six seven\n")
f.write("India is my country\n")
f.write("eight nine ten\n")
f.write("bye!")
f.close( )
f=open("first.txt","r")
lines=f.readlines()
f.close()
f1=open("second.txt","w")
for line in lines:
if 'a' not in line:
f1.write(line)
print("##File copied successfully##")
f1.close()
f=open("first.txt","r")
print("The contents of first file is:")
print(f.read())
f1=open("second.txt","r")
print("The contents of second file is:")
print(f1.read())

Output:
##File copied successfully##
The contents of first file is:
a quick brown fox
one two three four
five six seven
India is my country
eight nine ten
bye!
The contents of second file is:
one two three four
five six seven
eight nine ten
bye!

8
Program 6
Q. Create a CSV file with empno,name and salary. Search for a given empno and
display the name,salary and if not found display appropriate message.

Ans.
import csv
9
with open('myfile.csv','w') as csvfile:
mywriter=csv.writer(csvfile,delimiter=',')
ans='y'
while ans.lower()=='y':
eno=int(input("Enter Employee Number:"))
name=input("Enter Employee Name:")
salary=int(input("Enter Employee Salary:"))
mywriter.writerow([eno,name,salary])
ans=input("Add More?(Y)")
ans='y'
with open('myfile.csv','r') as csvfile:
myreader=csv.reader(csvfile,delimiter=',')
while ans=='y':
found=False
e=int(input("Enter Employee Number to search:"))
for row in myreader:
if len(row)!=0:
if int(row[0])==e:
print("NAME:",row[1])
print("SALARY:",row[2])
found=True
break
if not found:
print("EMPNO NOT FOUND")
ans=input("Search More?(Y)")

Output:

Enter Employee Number:101


Enter Employee Name:Ajay
Enter Employee Salary:10000
Add More?(Y)Y
Enter Employee Number:102
Enter Employee Name:Vijay
Enter Employee Salary:20000
Add More?(Y)n
Enter Employee Number to search:101
NAME: Ajay
SALARY: 10000
Search More?(Y)y
10
Enter Employee Number to search:103
EMPNO NOT FOUND
Search More?(Y)n

Program 7
Q. Write a random number generator that generates random numbers between 1
and 6 (simulates a dice).

Ans.
import random

11
import time
print("Press CTRL+C to stop the dice")
play='y'
while play=='y':
try:
while True:
for i in range(10):
print()
n=random.randint(1,6)
print(n,end='')
time.sleep(.00001)
except KeyboardInterrupt:
print("Your Number is:",n)
ans=input("Play More?(Y):")
if ans.lower()!='y':
play='n'
break

Output:
4Your Number is : 4
Play More? (Y) :y
Your Number is : 3
Play More? (Y) :y
Your Number is : 2
Play More? (Y) :n

Program 8
Q. Write a Python program to implement a stack using a list data-structure.

Ans.
# Implementation of List as stack
s=[]
12
c="y"
while c=="y":
print("1. PUSH")
print("2. POP")
print("3. Display")
choice=int(input("Enter your choice: "))
if choice==1:
a=input("Enter any number :")
s.append(a)
elif choice==2:
if s==[]:
print("Stack Empty")
else:
print("Deleted element is : ",s.pop())
elif choice==3:
l=len(s)
for i in range(l-1,-1,-1): # to display elements from last element to first
print(s[i])
else:
print("Wrong Input")
c=input("Do you want to continue or not? ")

Output:
1. PUSH
2. POP
3. Display
Enter your choice:1
Enter any number :5
Do you want to continue or not? y
1. PUSH
2. POP
3. Display
Enter your choice:1
Enter any number :t
Do you want to continue or not? y
1. PUSH
2. POP
3. Display
Enter your choice:1
13
Enter any number :66
Do you want to continue or not? y
1. PUSH
2. POP
3. Display
Enter your choice:1
Enter any number :88
Do you want to continue or not? y
1. PUSH
2. POP
3. Display
Enter your choice:3
88
66
t
5
Do you want to continue or not? y
1. PUSH
2. POP
3. Display
Enter your choice:2
Deleted element is : 88
Do you want to continue or not? y
1. PUSH
2. POP
3. Display
Enter your choice:2
Deleted element is : 66
Do you want to continue or not? y
1. PUSH
2. POP
3. Display
Enter your choice:3
t
5
Do you want to continue or not? n

14
Program 9
Q. Program to take a sample of ten phishing e-mails (or any text file) and find
most commonly occurring word(s)

Ans.
#Program to take 10 sample phishing and count the most commonly occurring
#word
15
phishingemail=["jackpotwin@lottery.com",
"claimtheprize@mymoney.com",
"youarethewinner@lottery.com",
"luckywinner@mymoney.com",
"spinthewheel@flipkart.com",
"dealwinner@snapdeal.com" ,
"luckywinner@snapdeal.com",
"luckyjackpot@americanlotter",
"claimtheprize@lootolottery.co",
"youarelucky@mymoney.com"
]
myd={}
for e in phishingemail:
x=e.split('@')
for w in x:
if w not in myd:
myd[w]=1
else:
myd[w]+=1
key_max = max(myd,key=myd.get)
print("Most Common Occuring word is :",key_max)

Output:
Most Common Occuring word is : mymoney.com

Program 10

Q. Input any number from user and calculate factorial of a number.

Ans.
# Program to calculate factorial of entered number
num = int(input("Enter any number :ʺ))
16
fact =1
n = num # storing num in n for printing
while num>0:
fact = fact * num
num- =1
print("Factorial of ", n , " is :",fact)

Output:

Enter any number :6


Factorial of 6 is : 720

Program 11

Q. Input any number from user and check if it is Prime no. or not.

Ans.
# To take input from the user
num = int(input("Enter a number: "))
17
# prime numbers are greater than 1
if num > 1:
# check for factors
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
break
else:
print(num,"is a prime number")

# if input number is less than


# or equal to 1, it is not prime
else:
print(num,"is not a prime number")

Output:

Enter a number: 7
7 is a prime number
>>>
Enter a number: 21
21 is not a prime number
>>>
Enter a number: 21
21 is not a prime number
>>>
Enter a number: 13
13 is a prime number

>>>
Enter a number: 9
9 is not a prime number
>>>
Enter a number: 21
21 is not a prime number

18
Program 12

Q. Program to search any word in given string/sentence.

Ans.
#Program to find the occurence of any word in a string
def countWord(str1,word):
s = str1.split()

19
count=0
for w in s:
if w==word:
count+=1
return count

str1 = input("Enter any sentence :")


word = input("Enter word to search in sentence :")
count = countWord(str1,word)
if count==0:
print("## Sorry! ",word," not present ")
else:
print("## ",word," occurs ",count," times ## ")

Output:

Enter any sentence :my computer your computer our computer everyones computer
Enter word to search in sentence :computer
## computer occurs 4 times ##

Enter any sentence :learning python is fun


Enter word to search in sentence :java
## Sorry! java not present

Program 13
Q. Using function find sum of all the elements of a list.

Ans.
def Sumlist(L1):
s=0
for i in L1:
s+=i

20
return s

L=eval(input("Enter the list: "))


print("sum of elements of list is",Sumlist(L))

Output:

Enter the list: [1,2,3,4]


sum of elements of list is 10

Program 14

Q. Write a program using user defined function that accepts base and exponent as
arguments and returns the value Base exponent where Base and exponent are
integers.

Ans.
#Function to calculate and display base raised to the power exponent

21
#The requirements are listed below:
#1. Base and exponent are to be accepted as arguments.
#2. Calculate Baseexponent
#3. Return the result (use return statement )
#4. Display the returned value.

def calcpow(number, power): #function definition


result = 1
for i in range(1,power+1):
result = result * number
return result
base = int(input("Enter the value for the Base: "))
expo = int(input("Enter the value for the Exponent: "))
answer = calcpow(base,expo) #function call
print(base,"raised to the power",expo,"is",answer)

Output:

Enter the value for the Base: 5


Enter the value for the Exponent: 4
5 raised to the power 4 is 625

Program 15

Q. Write a program using user defined function to compute the nth Fibonacci
number.

Ans.
def fibo(n1):
a=0

22
b=1
print(a)
print(b)
for i in range(1,n1-1):
c=a+b
print(c)
a,b=b,c

n=int(input("Enter the range:"))


fibo(n)

Output:

Enter the range:10


0
1
1
2
3
5
8
13
21
34

Program 16

Q. Write a program using user defined function that accepts length and breadth of a
rectangle and returns the area and perimeter of the rectangle.

Ans.
#Function to calculate area and perimeter of a rectangle
#The requirements are listed below:

23
#1. The function should accept 2 parameters.
#2. Calculate area and perimeter.
#3. Return area and perimeter.

def calcAreaPeri(Length,Breadth):
area = length * breadth
perimeter = 2 * (length + breadth)
#a tuple is returned consisting of 2 values area and perimeter
return (area,perimeter)
l = float(input("Enter length of the rectangle: "))
b = float(input("Enter breadth of the rectangle: "))
#value of tuples assigned in order they are returned
area,perimeter = calcAreaPeri(l,b)
print("Area is:",area,"\nPerimeter is:",perimeter)

Output:

Enter Length of the rectangle: 45


Enter Breadth of the rectangle: 66
Area is: 2970.0
Perimeter is: 222.0

Program 17
Q. Program to connect with database and store record of employee and display
records.
Ans.
import mysql.connector as mycon
con = mycon.connect(host='localhost',user='root',password='mysql')
cur = con.cursor( )
cur.execute("create database company")

24
cur.execute("use company")
cur.execute("create table employee(empno int, name varchar(20), dept
varchar(20),salary int)")
con.commit( )
choice=None
while choice!=0:
print("1. ADD RECORD ")
print("2. DISPLAY RECORD ")
print("0. EXIT")
choice = int(input("Enter Choice :"))
if choice == 1:
e = int(input("Enter Employee Number :"))
n = input("Enter Name :")
d = input("Enter Department :")
s = int(input("Enter Salary :"))
query="insert into employee values({},'{}','{}',{})".format(e,n,d,s)
cur.execute(query)
con.commit()
elif choice == 2:
query="select * from employee"
cur.execute(query)
result = cur.fetchall()
for row in result:
print(row[0],row[1],row[2],row[3])
elif choice==0:
con.close()
print("## Bye!! ##")
else:
print("## INVALID CHOICE ##")

Output:

1.ADD RECORD
2.DISPLAY RECORD
0.EXIT
Enter Choice :1
Enter Employee Number :1
Enter Name :AMIT
Enter Department :SALES
25
Enter Salary :9000
1.ADD RECORD
2.DISPLAY RECORD
0.EXIT
Enter Choice :1
Enter Employee Number :2
Enter Name :NITIN
Enter Department :IT
Enter Salary :80000
1.ADD RECORD
2.DISPLAY RECORD
0.EXIT
Enter Choice :2
1 AMIT SALES 9000
2 NITIN IT 80000
1.ADD RECORD
2.DISPLAY RECORD
0.EXIT
Enter Choice :0
## Bye!! ##

Program 18
Q. Program to connect with database and search employee number in table
employee
and display record, if empno not found display appropriate message.

Ans.
import mysql.connector as mycon
con=mycon.connect(host='localhost',user='root',password='mysql',database='compa
ny')
26
cur = con.cursor( )
ans='y'
while ans.lower( )=='y':
eno = int(input("ENTER EMPNO TO SEARCH :"))
query="select * from employee where empno={}".format(eno)
cur.execute(query)
result = cur.fetchall()
if cur.rowcount==0:
print("Sorry! Empno not found ")
else:
for row in result:
print(row[0],row[1],row[2],row[3])
ans=input("SEARCH MORE (Y/N) :")

Output:

ENTER EMPNO TO SEARCH :1


1 AMIT SALES 9000
SEARCH MORE (Y) :y
ENTER EMPNO TO SEARCH :2
2 NITIN IT 80000
SEARCH MORE (Y) :y
ENTER EMPNO TO SEARCH :4
Sorry! Empno not found
SEARCH MORE (Y) :n

Program 19
Q. Program to connect with database and update the employee record of entered
empno.

Ans.
import mysql.connector as mycon
con =
mycon.connect(host='localhost',user='root',password='mysql',database="company")

27
cur = con.cursor( )
ans='y'
while ans.lower()=='y':
eno =int(input("ENTER EMPNO TO UPDATE :"))
query="select * from employee where empno={}".format(eno)
cur.execute(query)
result = cur.fetchall()
if cur.rowcount==0:
print("Sorry! Empno not found ")
else:
for row in result:
print(row[0],row[1],row[2],row[3])
choice=input("\n## ARE YOUR SURE TO UPDATE ? (Y) :")
if choice.lower()=='y':
print("== YOU CAN UPDATE ONLY DEPT AND SALARY ==")
print("== FOR EMPNO AND NAME CONTACT ADMIN ==")
d = input("ENTER NEW DEPARTMENT,(LEAVE BLANK IF NOT
WANT TO CHANGE )")
s = int(input("ENTER NEW SALARY,(LEAVE BLANK IF NOT WANT
TO CHANGE ) "))
query="update employee set dept='{}',salary={} where
empno={}".format(d,s,eno)
cur.execute(query)
con.commit()
print("## RECORD UPDATED ## ")
ans=input("UPDATE MORE (Y) :")

Output:

ENTER EMPNO TO UPDATE :2


2 NITIN IT 80000

## ARE YOUR SURE TO UPDATE ? (Y) :y


== YOU CAN UPDATE ONLY DEPT AND SALARY ==
28
== FOR EMPNO AND NAME CONTACT ADMIN ==
ENTER NEW DEPARTMENT,(LEAVE BLANK IF NOT WANT TO CHANGE )
CS
ENTER NEW SALARY,(LEAVE BLANK IF NOT WANT TO CHANGE ) 90000
## RECORD UPDATED
## UPDATE MORE (Y) :N

Program 20
Q. Program to connect with database and delete the record of entered employee
number.

Ans.
import mysql.connector as mycon
con =
mycon.connect(host='localhost',user='root',password='mysql',database='company')

29
cur = con.cursor( )
ans='y'
while ans.lower( )=='y':
eno = int(input("ENTER EMPNO TO DELETE :"))
query="select * from employee where empno={}".format(eno)
cur.execute(query)
result = cur.fetchall( )
if cur.rowcount==0:
print("Sorry! Empno not found ")
else:
for row in result:
print(row[0],row[1],row[2],row[3])
choice=input("\n## ARE YOUR SURE TO DELETE ? (Y) :")
if choice.lower( )=='y':
query="delete from employee where empno={}".format(eno)
cur.execute(query)
con.commit()
print("=== RECORD DELETED SUCCESSFULLY! ===")
ans=input("DELETE MORE ? (Y) :")

Output:

ENTER EMPNO TO DELETE :2


2 NITIN CS 90000

## ARE YOUR SURE TO DELETE ? (Y) :y


=== RECORD DELETED SUCCESSFULLY! ===

STRUCTURED QUERY LANGUAGE


Write SQL commands & their outputs on the basis of table EMP
Table:EMP

30
Empn EmpName Job Mgr Hiredate Sal comm Deptno
o
7839 KING PRESIDEN 7839 17-Nov-81 5000 10
T

7698 BLAKE MANAGER 7839 1-May-81 2850 30

7782 CLARK MANAGER 7839 9-Jun-81 2450 10

7566 JONES MANAGER 7698 2-Apr-81 2975 20

7654 MARTIN SALESMAN 7698 28-Sep-81 1250 1400 30

7499 ALLEN SALESMAN 7698 20-Feb-81 1600 300 30

7844 TURNER SALESMAN 7698 8-Feb-81 1500 0 30

7900 JAMES CLERK 7698 3-Dec-81 950 30

7521 WARD SALESMAN 7698 22-Feb-81 1250 500 30

7902 FORD ANALYST 7566 3-Dec-81 1600 NULL

7369 SMITH CLERK 7902 13-Dec-80 1500 NULL

7788 SCOTT ANALYST 7566 17-Dec-81 950 20

7876 ADAMS CLERK 7788 09-Jan-82 1250 20

7934 MILLER CLERK 7782 23-Jan-83 1300 NULL

Fig. 1
1. To show the content of the EMP table
Ans. SELECT * FROM EMP;
Output:- Fig. 1
2. To display distinct jobs from the EMP table

31
Ans. SELECT DISTINCT Job FROM EMP;
Output:- PRESIDENT
MANAGER
SALESMAN
CLERK
ANALYST

3. To display EmpName & Salary for employees having their salary


more than 2900
Ans. SELECT EmpName, Sal FROM EMP WHERE Sal>2900;
Output:- EmpName Sal
KING 5000
JONES 2975
FORD 3000
SCOTT 3000

4. To display names & salary for employees having salary between


3000 to 5000
Ans. SELECT EmpName, Sal FROM EMP WHERE Sal BETWEEN
3000 AND 5000;
Output:- EmpName Sal
KING 5000
32
FORD 3000
SCOTT 3000

5. To display employee no. & names of employees belonging to jobs


‘Manager’ or ‘Analyst’
Ans. SELECT Empno,EmpName FROM EMP WHERE Job=
‘Manager OR Job= ‘Analyst’;
Output: Empno EmpName
7698 BLAKE
7782 CLARK
7566 JONES
7902 FORD
7788 SCOTT
6. To display employee no. & names for those employees whose name
starts with ‘A’
Ans. SELECT Empno,EmpName FROM EMP WHERE EmpName
LIKE ‘A%’;
Output:- Empno EmpName
7499 ALLEN
7876 ADAMS

7. To display employee no. & names of employees whose names ends


with ‘RD’
33
Ans. SELECT Empno,EmpName FROM EMP WHERE EmpName
LIKE ‘%RD’;
Output:- EmpNo EmpName
7521 WARD
7902 FORD

8. To display employee no. & names of employees who have four


letter names ending with ‘D’
Ans. SELECT Empno,EmpName FROM EMP WHERE EmpName
LIKE ‘_ _ _ D’;
Output:- Empno EmpName
7521 WARD
7902 FORD
9. To display the list of employees having employee no. , names & job
having salary more than 2900 in the alphabetical order of their names
Ans. SELECT Empno,EmpName,Job FROM EMP WHERE
sal>2900 ORDER By EmpName;
Output:- EmpNo EmpName Job
7902 FORD ANALYST
7566 JONES MANAGER
7839 KING PRESIDENT
7788 SCOTT ANALYST

34
10. To calculate the total salary for employees having deptno=10
Ans. SELECT SUM(Sal) FROM EMP WHERE Deptno=10;
Output:- 7450

11. To count the number of employees in EMP table


Ans. SELECT COUNT(*) FROM EMP;
Output:- 14

12. To calculate the number of employees in each grade & sum of


commission for each grade of employees
Ans. SELECT Job, COUNT(*), SUM(Comm) FROM EMP GROUP
BY Job;
Output:- Job Count(*) Sum(comm)
PRESIDENT 1
MANAGER 3
SALESMAN 4 2200
CLERK 4
ANALYST 2

35
13. To insert a new row in the EMP table with the following data:
7950, “RAM”, “ANALYST”,7900,{28/03/84},6000
Ans. INSERT INTO EMP VALUES(7950, “RAM”,
“ANALYST”,7900,{28/03/84},6000);
Output:- This row will be inserted at the end of table.

14. To add a new column tele_no of type integer


Ans. ALTER TABLE EMP ADD(tele_no int);
Output:- This column would be added after column Deptno

15. To increase the salary of all employees by 5%


Ans. UPDATE EMP SET Sal=Sal+Sal*5/100

16. To delete all rows of table Emp


Ans. DELETE FROM EMP;

36

You might also like