pract_12 _IP_practice_A_B
pract_12 _IP_practice_A_B
Q2. Consider the following table ITEM write following queries : [7]
ITEM
Column Name Data Type Constraint Name
Item_Code integer Primary key
Item_Name varchar(20)
Price integer
Brand_Name varchar(15)
Write SQL statement to –
(a) Create the above table.
(b) Insert few records in the above table.
e.g.
2001, “Refrigerator”, 8500, “SONY”
2002, “Refrigerator ”, 17500, “LG”
2003, “TV ”, 40000, “ONIDA”
2004, “Computer ”, 60000, “SAMSUNG”
2005, “Smartphone ”, 22500, “SAMSUNG”
2006, “AC ”, 32500, “LG”
2007, “TV ”, 40000, “SONY”
(c) To display Item_code, Item_Name and Brand_Name of those items, whose price is between 20000 and
40000 (both value inclusive).
(d) To display Item_code, Price and Brand_Name of the item, which has Item_Name as “Computer”..
(e) To increase the price of all the items by 10%
(f) To delete the records whose Brand is “ONIDA”.
g) to display the average price of the items.
Solutions Set A
Q1 Write a program for the following : ( Python) [8marks]
import pandas as pd
'Test':[3543,2578,2280,2158,1879],
'ODI':[2245,2165,2080,1957,1856],
'T20':[1925,1853,1522,1020,980]
Srno=[1,2,3,4,5]
df1=pd.DataFrame(dic1,index=Srno)
print(df1)
total_row=len(df1.axes[0])
total_col=len(df1.axes[1])
print(df1[df1.ODI>2000])
x=df1['Name']
y=df1['Test']
plt.plot(x,y)
plt.title(" Chart")
plt.xlabel("Names")
plt.ylabel("Runs in Test")
plt.show()
Q2 SQL commands (7marks) Solutions
mysql> create database pract1;
Brand_name varchar(20)
);
(c) To display Item_code, Item_Name and Brand_Name of those items, whose price is between 20000
and 40000 (both value inclusive).
Mysql> Select item_code,item_name, Brand_name from items where price between 20000 and 40000;
(d) To display Item_code, price and Brand_name of the item, which has item_name as “Computer”.
Mysql> Select item_code,price, Brand_name from items where item_name=”Computer”;
1003,"Ajay","Rampur","sales",51000
1004,"Sanjay","Jodhpur","account",51000
1005,"Vijay","Jaipur","purchase",48000
1006,"Shobhit","Jodhpur","account",31000
Solutions Set B
Q1 Write a program for the following : ( Python)[8 marks]
import pandas as pd
dic1={'Name':["Naman","Nandini","Nakshatra","Shailesh","Trisha","Manisha",'Hetvee','Neel','Mayur'],
'Class':['XII','X','X','XI','XII','XII','XII','X','XII'],
'Gender':['M','F','F','M','F','F','F','M','M'],
'City':['Anand','Baroda','Baroda','Surat','Anand','Anand','Junagardh','Godhara','Surat'],
'Marks':[453,551,553,458,430,530,555,559,570]
rno=[1,2,3,4,5,6,7,8,9]
df1=pd.DataFrame(dic1,index=rno)
print(df1)
total_row=len(df1.axes[0])
total_col=len(df1.axes[1])
print(df1[df1.Marks<550])
x=df1['Name']
y=df1['Marks']
plt.plot(x,y)
plt.title(" Chart")
plt.xlabel("Names")
plt.ylabel("Marks")
plt.show()
Q2 SQL Commands Solutions (7marks)
MYSQL> create database pract1;
Emp_add varchar(25),
department varchar(15),
salary integer
);
(e) To display all the employee’s name length and first 3 character
mysql> select * from employee where department="accounts";
(f)Display all the records whose salary is greater than 35000 and less than 55000.
mysql> select * from employee where salary between 35000 and 55000;
(g) To show the minimum and maximum salary on the basis of department wise .
mysql> select department,min(salary),max(salary) from employee group by department;