Class 12 IP Practical File Question
Class 12 IP Practical File Question
Python Program
Q.1 Write a Python Program to implement all user defined functions of a list
x=0
L = [1,2,3,4]
while (x != 0):
print("1. append in list")
print("2. Insert in a list")
print("3. Find length of list")
print("4. To count occurrence of an element")
print("5. Extend a list")
print("6. Find the sum of list elements")
print("7. Find the index of given element")
print("8. Find the minimum element in a list")
print("9. Find the maximum element in a list")
print("10.To pop element")
print("11.To remove element")
print("12.To use del ")
print("13.To reverse a list")
print("14.To sort a list")
print(“0. For Exit”)
x = int(input("Enter choice = "))
if (x == 1):
print("Original list ", L)
val = int(input("Enter a value to be appended -> "))
L.append(val)
print("List after append ", L)
elif (x == 2):
val = int(input("Enter a value to be inserted -> "))
loc = int(input("Enter a location to insert -> "))
L.insert(loc,val)
print("Original list ", L)
print("List after insert ",L)
elif (x == 3):
n = len(L)
print("Length of list ",n)
elif (x == 4):
val = int(input("Enter a value whose occurrence want to count -> "))
n = L.count(val)
print(val," occur ",n," times in list", L)
elif (x == 5):
M = [100,200,300,4000]
L.extend(M)
print("List after extend ",L)
elif (x == 6):
n = sum(L)
print("Sum of list elements ",n)
elif (x == 7):
print(L)
print("1. To give index when no starting and ending value given")
print("2. To give index after given starting index value")
print("3. To give index after given starting and ending index value")
y = int(input("Enter choice -> "))
if (y == 1):
val = int(input("Enter a value whose index you want -> "))
n = L.index(val)
print("index of ", val," is ", n)
elif (y == 2):
val = int(input("Enter a value whose index you want -> "))
loc = int(input("Enter a starting location -> "))
n = L.index(val,loc)
print("index of ", val," is ", n)
elif (y == 3):
val = int(input("Enter a value whose index you want -> "))
loc = int(input("Enter a starting location -> "))
end = int(input("Enter a ending location -> "))
n = L.index(val,loc,end)
print("index of ", val," is ", n)
elif (x == 8):
n = min(L)
print("Minimum element of list ",n)
elif (x == 9):
n = max(L)
print(" maximum element of list ",n)
elif (x == 10):
print("1. To pop last element ")
print("2. To pop a particular index")
y = int(input("Enter the choice"))
if (y == 1):
print("List before pop ",L)
n = L.pop()
print("List after pop ",L)
elif (y == 2):
loc = int(input("Enter a location to pop -> "))
print("List before pop ",L)
n = L.pop(loc)
print("List after pop ",L)
elif (x == 11):
print("List before remove ",L)
val = int(input("Enter a value want to remove -> "))
L.remove(val)
print("List after remove ",L)
elif (x == 12):
print("1. To delete complete list")
print("2. To delete a particular element from list")
y = int(input("Enter the choice"))
if (y == 1):
print("List before del ",L)
del L
print("List after del ",L)
elif (y == 2):
print("List before pop ",L)
loc = int(input("Enter a location of element to delete -> "))
del L[loc]
print("List after del ",L)
elif (x == 13):
print("List before reverse",L)
L.reverse()
print("List after reverse ",L)
elif (x == 14):
print("List before sort",L)
L.sort()
print("List in ascending order ",L)
L.sort(reverse=True)
print("List in descending order ",L)
Q.2 Write a Python Program to implement all user defined functions of Dictionary.
x=0
Stud = {'Name':'Arun','Class':12}
while x != 0:
print("1. Creating a dictionary")
print("2. Updating dictionary")
print("3. Printing Dictionary keys")
print("4. Printing Dictionary values")
print("5. Printing Dictionary items")
print("6. Printing the value of given key")
print("7. Find Dictionary length")
print("8. Printing key and value using loop")
print("9. Printing key and value using loop and items() function")
print("10.Check in and not in membership operator")
print("11.Update dictionary")
print("12.Use del function")
print("13.Use pop function")
print("14.Use popitem() function")
print("15.Use clear function")
print("16.copy dictionary")
print("17.Sort keys")
print(“0. For Exit”)
x = int(input("Enter choice = "))
if x == 1:
ch1 = 'y'
while ch1=='y':
key = input("Enter a key -> ")
val = input("Enter a value of key -> ")
Stud[key] = val
print(Stud)
ch1 = input("Do You want to continue Y/N ")
if x == 2:
ch1 = 'y'
while ch1=='y':
key = input("Enter a key -> ")
val = input("Enter a value of key -> ")
Stud.update({key:val})
print(Stud)
ch1 = input("Do You want to continue Y/N ")
if x == 3:
print("Dictinary keys ",Stud.keys())
if x == 4:
print("Dictinary keys ",Stud.values())
if x == 5:
print("Dictinary keys ",Stud.items())
if x == 6:
key = input("Enter key whose value required ")
print(Stud[key])
print(Stud.get(key))
if x == 7:
print("Lenth of Dictionary ",len(Stud))
if x == 8:
for key in Stud:
print(key, " value is ", Stud[key])
if x == 9:
for key, value in Stud.items():
print({key},":",{value})
for key in Stud.key():
print(key)
for value in Stud.values():
print(value)
if x == 10:
print('Name' in Stud)
print('Address' not in Stud)
print('Fees' in Stud)
if x == 11:
val = input("Enter a new name -> ")
Stud['Name'] = val
print(Stud)
Stud.update({'Name':'Rahul'})
print(Stud)
if x == 12:
print("1. To delete a particular element from list")
print("2. To delete complete list")
y = int(input("Enter the choice"))
if y == 1:
key = input("Enter a key to be deleted -> ")
del Stud[key]
print(Stud)
if y == 2:
del Stud
print(Stud) #this will cause an error because "Stud" no longer exists.
if x == 13:
key = input("Enter a key to be popped -> ")
Stud.pop(key)
print(Stud)
if x == 14:
Stud.popitem()
print(Stud)
if x == 15:
Stud.clear()
print(Stud)
if x == 16:
print("Stud ", Stud)
Stud1 = Stud
print("Stud1 = ",Stud1)
Stud1['Name'] = 'Rohan'
print("Stud after change in Stud1 ",Stud)
Stud2 = Stud.copy()
Stud2['Name'] = 'Romi'
print("stud after change is Stud2 ",Stud)
Stud3 = dict(Stud)
Stud3['Name'] = 'Vimal'
print("Stud after change in Stud 3 ",Stud)
if x == 17:
print(sorted(Stud))
Q.3 Write a Python Program to create the Series data structure using list items and display its.
import pandas as pd
y=pd.Series([15,18,17,15,20,12],["A","b","c","d","e","f"],dtype="int32")
print(y)
Output
A 15
b 18
c 17
d 15
e 20
f 12
dtype: int32
Q.4 Write a Python Program to create the Series data structure using Dictionary and display all its
attributes.
import pandas as pd
y=pd.Series({"Rollno":1,"Name":"Amit","Class":11,"City":"Jaipur","DOB":None})
print("Your Series Data Structure As Follows:\n",y,"\n")
print("Your index As Follows:",y.index)
print("Your Data As Follows:",y.values)
print("Data Type of Series:",y.dtype)
print("Shape of Series is:",y.shape)
print("Number of Dimension:",y.ndim)
print("Size of Series:",y.size)
print("Number of Bytes:",y.nbytes)
print("Have None Data:",y.hasnans)
print("Empty Series:",y.empty)
Output
import pandas as pd
x=1
L=pd.Series([11,16,13,19,10,15,17,12])
while (x != 0):
print("1. Add Or Update an Item in Series")
print("2. To Remove an Item from Series")
print("3.To Display Series")
print("4. To Display the Top Rows Of Series")
print("5. To Display the Bottom Rows Of Series")
print("6. To Display the Given Index Number of Series")
print("7. Find the sum of Series Items")
print("8. Find the Square of Series Items")
print("9. Find the minimum element in a Series")
print("10. Find the maximum element in a Series")
print("11. Find the total item in a Series")
print("12.Sort Series in Order of Data")
print("13.Sort Series in Order of Index in Descending Order")
print("14.To Change Index No ")
print("0. For Exit")
x = int(input("Enter choice = "))
if (x == 1):
ind = int(input("Enter Index Number"))
val = int(input("Enter a value to be Add "))
L[ind]=val
elif (x == 2):
val = int(input("Enter Index No to be Removed "))
L=L.drop(val)
print("Item Removed")
elif (x == 3):
print(L)
elif (x == 4):
val = int(input("Number of Rows want to display from Top "))
print(L.head(val))
elif (x == 5):
val = int(input("Number of Rows want to display from Bottom "))
print(L.tail(val))
elif (x == 6):
val = int(input("Enter the Index Number want to display"))
print(L[val])
elif (x == 7):
print("Total of the Item:",L.sum())
elif (x == 8):
print("Square of the Item:",L**2)
elif (x == 9):
print("Minimum Value:",L.min())
elif (x == 10):
print("Maximum Value:",L.max())
elif (x == 11):
print("Total of the Item:",L.count())
elif (x == 12):
print("Series After Sorting Of Data:\n",L.sort_values())
elif (x == 13):
print("Series After Sorting Of index in descending order:\n",L.sort_index(ascending=False))
elif (x == 14):
oind = int(input("Enter Index Number want to change"))
nind = int(input("Enter New Index Number"))
L=L.rename({oind:nind})
print(L)
print("\n--------------------------------------------------------------------\n\n\n")
Q.6 Write a Python Program to create the DataFrame data structure using list items and display its.
import pandas as pd
b=pd.DataFrame([[1,"Mohan",12],[2,"Kapil",11],[3,"Amita",11],[4,"Madhu",11],[5,"Priya",12]],columns=
["rollno", "name","age"],index=["S1","S2","S3","S4","S5"])
print(b)
Output
rollno name age
S1 1 Mohan 12
S2 2 Kapil 11
S3 3 Amita 11
S4 4 Madhu 11
S5 5 Priya 12
Q.7 Write a Python Program to create the Series data structure using Dictionary and display all its
attributes.
import pandas as pd
y=pd.DataFrame({"Physics":[20,10,12,12],"Chemistry":[14,15,14,14],"Biology":[12,15,16,18],"English":[18,20,2
0,19]},index=["C1","c2","c3","C4"])
print("Your Data Frame As Follows:\n",y,"\n")
print("Your index As Follows:",y.index,"\n")
print("Your Columns As Follows:",y.columns,"\n")
print("Details of Both Axis are As Follows:",y.axes,"\n")
print("Your Data As Follows:",y.values,"\n")
print("Data Type of Series:",y.dtypes,"\n")
print("Shape of Series is:",y.shape,"\n")
print("Number of Dimension:",y.ndim,"\n")
print("Size of Series:",y.size,"\n")
print("Empty Series:",y.empty,"\n")
print("Transpose of Data Frame:\n",y.T)
Output
Your Data Frame As Follows:
Physics Chemistry Biology English
C1 20 14 12 18
c2 10 15 15 20
c3 12 14 16 20
C4 12 14 18 19
Details of Both Axis are As Follows: [Index(['C1', 'c2', 'c3', 'C4'], dtype='object'), Index(['Physics', 'Chemistry', 'Bi
ology', 'English'], dtype='object')]
Size of Series: 16
import pandas as pd
L=pd.DataFrame({"Rollno":[101,102,103,104],"Name":["Abhay","Somya","Priya","Divya"],"Physics":[20,10,12,1
2],"Chemistry":[14,15,14,14],"Biology":[12,15,16,18],"English":[18,20,20,19]},index=["S1","S2","S3","S4"])
print(L)
x=1
while (x != 0):
print("1. To Display a Column from Data Frame")
print("2. To Display a Row From Data Frame")
print("3. To Display DataFrame")
print("4. To Display the Top Rows Of Data Fram")
print("5. To Display the Bottom Rows Of Series")
print("6. To Display the Specific Data from Data Frame")
print("7. To Add / Update a Row in Data Frame")
print("8. To Add a Column in Data Frame")
print("9. To Update a Specific Data in Data Frame")
print("10.To Delete a Row from Data Frame")
print("11.To Delete a Column from Data Frame")
print("0. For Exit")
x = int(input("Enter choice = "))
if (x == 1):
ind = input("Enter Column Name")
print(L[ind])
elif (x == 2):
ind = input("Enter Row Index No")
print(L.loc[ind])
elif (x == 3):
print(L)
elif (x == 4):
val = int(input("Number of Rows want to display from Top "))
print(L.head(val))
elif (x == 5):
val = int(input("Number of Rows want to display from Bottom "))
print(L.tail(val))
elif (x == 6):
ival = input("Enter the Index Number want to display")
cval = input("Enter the Column Name want to display")
print(L.loc[ival,cval])
elif (x == 7):
ival = input("Enter the Index Number want to Add / Modify")
rn = int(input("Enter the Roll No:"))
nm = input("Enter the Name:")
phy = int(input("Enter Physics Marks"))
chem = int(input("Enter Chemistry Marks:"))
bio = int(input("Enter Biology Marks:"))
eng = int(input("Enter English Marks:"))
L.loc[ival]=[rn,nm,phy,chem,bio,eng]
elif (x == 8):
cval = input("Enter the Column Name want to Add")
L[cval]=None
elif (x == 9):
ival = input("Enter the Index Number")
cval = input("Enter the Column Name")
val = input("Enter the Data:")
L.loc[ival,cval]=val
elif (x == 10):
val = input("Enter the Index Number Want to Delete")
L=L.drop(val)
elif (x == 11):
val = input("Enter the Column Name Want to Delete")
del L[val]
print("\n--------------------------------------------------------------------\n\n\n")
Q.9 Write a Python Program to change column and index, sorting of data in data frame.
import pandas as pd
L=pd.DataFrame({"Rollno":[101,102,103,104],"Name":["Abhay","Somya","Priya","Divya"],"Physics":[20,10,12,1
2],"Chemistry":[14,15,14,14],"Biology":[12,15,16,18],"English":[18,20,20,19]},index=["S1","S2","S3","S4"])
print(L)
x=1
while (x != 0):
print("1. To Display Data Frame")
print("2. To Change Column Name")
print("3. To Change Index Number")
print("4. To Sort the Data by Column Name")
print("5. To Sort the Data by Index Number")
print("0. For Exit")
x = int(input("Enter choice = "))
if (x == 1):
print(L)
elif (x == 2):
ocol = input("Enter Column Name want to change")
ncol = input("Enter New Column Name")
L=L.rename(columns={ocol:ncol})
elif (x == 3):
oind = input("Enter Index Number want to change")
nind = input("Enter New Index Number")
L=L.rename(index={oind:nind})
elif (x == 4):
col = input("Enter Column Name")
L=L.sort_values(col)
print(L)
elif (x == 5):
L=L.sort_index()
print(L)
print("\n--------------------------------------------------------------------\n\n\n")
Q.10 Write a Python Program to implement all operations on a DataFrame.
import pandas as pd
L=pd.DataFrame({"Rollno":[101,102,103,104],"Name":["Abhay","Somya","Priya","Divya"],"Physics":[20,10,12,1
2],"Chemistry":[14,15,14,14],"Biology":[12,15,16,18],"English":[18,20,20,19]},index=["S1","S2","S3","S4"])
print(L)
x=1
while (x != 0):
print("1. To Display Data Frame")
print("2. To Count the total number of Item in Each Column")
print("3. To Find the sum of Each Column")
print("4. To Find the Minimum Value in Each Column")
print("5. To Find the Maximum Value in Each Column")
print("6. To Count the total number of Item in Each Row")
print("7. To Find the sum of Each Row")
print("8. To Find the Minimum Value in Each Row")
print("8. To Find the Maximum Value in Each Row")
print("0. For Exit")
x = int(input("Enter choice = "))
if (x == 1):
print(L)
elif (x == 2):
ans=L.count(axis=0)
print(ans)
elif (x == 3):
ans=L.sum(axis=0,numeric_only=True)
print(ans)
elif (x == 4):
ans=L.min(axis=0,numeric_only=True)
print(ans)
elif (x == 5):
ans=L.max(axis=0,numeric_only=True)
print(ans)
elif (x == 6):
ans=L.count(axis=1)
print(ans)
elif (x == 7):
ans=L.sum(axis=1,numeric_only=True)
print(ans)
elif (x == 8):
ans=L.min(axis=1,numeric_only=True)
print(ans)
elif (x == 9):
ans=L.max(axis=1,numeric_only=True)
print(ans)
print("\n--------------------------------------------------------------------\n\n\n")
Q.11 Write a Python program to display the data of each student individually.
import pandas as pd
L=pd.DataFrame({"Rollno":[101,102,103,104],"Name":["Abhay","Somya","Priya","Divya"],"Physics":[20,10,12,1
2],"Chemistry":[14,15,14,14],"Biology":[12,15,16,18],"English":[18,20,20,19]},index=["S1","S2","S3","S4"])
import pandas as pd
L=pd.DataFrame({"Rollno":[101,102,103,104],"Name":["Abhay","Somya","Priya","Divya"],"Physics":[20,10,12,1
2],"Chemistry":[14,15,14,14],"Biology":[12,15,16,18],"English":[18,20,20,19]},index=["S1","S2","S3","S4"])
import pandas as pd
L=pd.DataFrame({"Rollno":[101,102,103,104],"Name":["Abhay","Somya","Priya","Divya"],"Physics":[20,10,12,1
2],"Chemistry":[14,15,14,14],"Biology":[12,15,16,18],"English":[18,20,20,19]},index=["S1","S2","S3","S4
"])
L.to_csv("d://py/mydata.csv")
data=pd.read_csv("d://py/mydata.csv",index_col=0)
print(data)
Output
Rollno Name Physics Chemistry Biology English
S1 101 Abhay 20 14 12 18
S2 102 Somya 10 15 15 20
S3 103 Priya 12 14 16 20
S4 104 Divya 12 14 18 19
Q.14 Write a Python Program to implement all operations on a DataFrame using csv file.
Notepad:
rollno,name,hindi,english,maths
Python code:
import pandas as pd
x=1
while (x != 0):
L=pd.read_csv("d://py/details.csv",index_col="rollno")
print("1. To Display a Column from Data Frame")
print("2. To Display a Row From Data Frame")
print("3. To Display DataFrame")
print("4. To Display the Top Rows Of Data Fram")
print("5. To Display the Bottom Rows Of Series")
print("6. To Display the Specific Data from Data Frame")
print("7. To Add / Update a Row in Data Frame")
print("8. To Update a Specific Data in Data Frame")
print("9.To Delete a Row from Data Frame")
print("10. To Change Roll Number")
print("11. To Sort the Data by Column Name")
print("12. To Sort the Data by Roll Number")
if (x == 1):
ind = input("Enter Column Name")
print(L[ind])
elif (x == 2):
ind = int(input("Enter Roll Number"))
print(L.loc[ind])
elif (x == 3):
print(L)
elif (x == 4):
val = int(input("Number of Rows want to display from Top "))
print(L.head(val))
elif (x == 5):
val = int(input("Number of Rows want to display from Bottom "))
print(L.tail(val))
elif (x == 6):
ival = int(input("Enter the Roll Number"))
cval = input("Enter the Column Name")
print(L.loc[ival,cval])
elif (x == 7):
rn = int(input("Enter the Roll Number want to Add / Modify"))
nm = input("Enter the Name:")
hin = int(input("Enter Hindi Marks"))
eng = int(input("Enter English Marks:"))
math = int(input("Enter Maths Marks:"))
L.loc[rn]=[nm,hin,eng,math]
elif (x == 8):
ival = int(input("Enter the Roll Number"))
cval = input("Enter the Column Name")
val = input("Enter the Data:")
L.loc[ival,cval]=val
elif (x == 9):
val = int(input("Enter the Roll Number Want to Delete"))
L=L.drop(val)
elif (x == 10):
oind = int(input("Enter Roll Number want to change"))
nind = int(input("Enter New Roll Number"))
L=L.rename(index={oind:nind})
elif (x == 11):
col = input("Enter Column Name")
L=L.sort_values(col)
print(L)
elif (x == 12):
L=L.sort_index()
print(L)
L.to_csv("d://py/details.csv")
print("\n--------------------------------------------------------------------\n\n\n")
Q.15 Write a Python Program to create a line graph for fare from Jaipur to different cities.
import matplotlib.pyplot as py
py.figure(figsize=(10,10))
a=["Ajmer","Kota","Alwar","Bikaner"]
b=[200,500,350,450]
py.plot(a,b,linewidth=5)
import pandas as pd
import matplotlib.pyplot as py
L=pd.DataFrame({"Rollno":[101,102,103,104],"Name":["Abhay","Somya","Priya","Divya"],"Physics":[20,10,12,1
2],"Chemistry":[14,15,14,14],"Biology":[12,15,16,18],"English":[18,20,20,19]},index=["S1","S2","S3","S4"])
print(L)
py.figure(figsize=(10,10))
import matplotlib.pyplot as py
py.figure(figsize=(15,10))
a=[2016,2017,2018,2019,2020]
b=[1200,1500,1350,1450,1800]
py.bar(a,b,color="orange")
py.title("Yearwise Student in School")
py.xlabel("Year")
py.ylabel("Number of Student")
py.show()
Q.18 Write a Python Program to create a horizontal bar graph for number of student in school in each class
import matplotlib.pyplot as py
py.figure(figsize=(15,10))
py.barh(['I','II','III','IV','V','VI','VII','VIII'],[130,135,142,137,139,146,175,200])
import pandas as pd
import matplotlib.pyplot as py
import numpy as np
L=pd.read_csv("d://py/details.csv",index_col="rollno")
print(L)
l=L["name"].count()
x=np.arange(l)
py.figure(figsize=(10,10))
import matplotlib.pyplot as py
py.figure(figsize=(15,10))
py.hist([10,12,15,12,11,12,15,12,12,11,10,10,11,12,11,12,11,10,13,14])
py.title("Age Chart")
py.xlabel("Age")
py.ylabel("Number of Student")
py.show()
MySQL Programs
1. Consider the table Student given below, write command for creating and insert data.
Table : STUDENT
Sr_no Name Father Name Class DOB Father Income
1005 Ravi Sharma Nilesh 6 2007-12-12 300000
2785 Mansi Gupta Karan 5 2008-02-19 400000
6587 Kapil Gupta Vishnu 5 null 500000
1265 Raji Jain Naresh 6 2008-01-02 540000
4457 Lalit Sharma Lokendra 5 null 450000
6856 Naveen Gupta Mahesh 5 2008-03-13 400000
(i) To display all data of students whose name ends with Gupta
Ans. Select * from student where name like ‘%gupta’;
(ii) To display the name of students who father income is more than 400000.
Ans. Select name from student where fatherincome > 400000;
(iii) To display Sr. number, name and father name of class 6 student
Ans. Select srno,name,fathername from student where class=6;
(iv) To display all data of student who born before 26 January 2008.
Ans. Select * from student where dob < ‘2008-01-26’;
(v) To display father name of those student whose name start with ‘R’ alphabet.
Ans. Select fathername from student where name like ‘R%’;
(vii) To delete the data of those student who born after 01 July 2008.
Ans. delete from student where dob > ‘2008-07-01’;
2. Write the MySQL command for (i) to (iv) & (x) and output for (v) to (ix) query
Table: PROJECTS
(i) To list the ProjSize of projects whose ProjName ends with LITL.
Ans. Select projsize from projects where name like ‘%litl’;
(ii) To list ID, name, size and Cost of all the projects in descending order of cost.
Ans. Select id, projname, projsize, cost from projects order by cost desc;
(iii) Change the cost of projects to increase of 10000 which have cost less than 100000.
Ans. Update projrcts set cost=cost+10000 where cost <100000;
(iv) Change the projsize of Medium to Small which have cost 50000;
Ans. Update projects set projsize=’small’ where cost <50000;
(vi) SELECT ID, ProjSize FROM projects where cost >= 200000;
Ans. ID ProjSize
2 Large
3 Large
(ii) To display all data of flights which have origin name end with ‘i’.
Ans. Select * from flight where origin like ‘%i’;
(iii) To display flight details of the flight whose flight date is after 2007.
Ans. Select * from flight where flightdate>’2007-12-31’
(x) To display the total seats and amount in group of their Origin
Ans. Select sum(seats), sum(rate) from flight group by origin.
4. Consider the table given below. Write the answer for question (i), SQL queries for question (ii) to
(vii) & output for question (viii) to (x).
Table : Salesperson
SID Name Phone DOB Salary Area
S101 Amit Kumar 98101789654 1967-01-23 67000 North
S102 Deepika Sharma 99104567834 1992-09-23 32000 South
S103 Vinay Srivastav 98101546789 1991-06-27 35000 North
S104 Kumar Mehta 88675345789 1967-10-16 40000 East
S105 Rashmi Kumar 98101567434 1972-09-20 50000 South
Note : Columns SID and DOB contain Sales Person Id and Data of Birth respectively.
(ii) Display names of Salespersons and Salaries who have salaries in the range 30000 to 40000
Ans. Select name from salesperson where salary between 30000 and 40000;
(iii) To list Names, & DOB of Salespersons who were born before 1st November, 1992.
Ans. Select name,dob from salesperson where dob < ‘1992-11-01’;
(viii) SELECT * FROM salesperson WHERE Name LIKE ‘%Kumar%’ OR Name LIKE ‘%Sharma%’;
Ans.
SID Name Phone DOB Salary Area
S101 Amit Kumar 98101789654 1967-01-23 67000 North
S102 Deepika Sharma 99104567834 1992-09-23 32000 South
S104 Kumar Mehta 88675345789 1967-10-16 40000 East
S105 Rashmi Kumar 98101567434 1972-09-20 50000 South
(ix) SELECT Name, Phone FROM Salesperson WHERE Salary>40000 AND Area=’South’;
Ans.
Name Phone
Rashmi Kumar 98101567434
(x) SELECT SID, Name, Phone FROM Salesperson WHERE Area LIKE ‘%th’;
Ans.
SID Name Phone
S101 Amit Kumar 98101789654
S102 Deepika Sharma 99104567834
S103 Vinay Srivastav 98101546789
S105 Rashmi Kumar 98101567434