SET 1
SET 1
SET 1
Sharad 66 63 49 89
Mansi 86 67 97 90
Kanika 92 78 45 66
Ramesh 58 64 55 78
Ankita 53 75 88 69
Pranay 98 79 88 96
The Names of the students are row labels and the names (UT, HalfYearly, UT2 and Final are column
lables. Answer the following questions based on the above DataFrame.
1. Add a new row for the student with name Aastha and marks equal to 49, 56, 71,58.
2. Add a new column Internal Assessment with values ['A’, ‘A,’’B’,’A’,’C’,’B’,’C’].
3. Rename Pranay to Puneet.
4. Display marks in Half Yearly and Final of all students.
5 Display marks of Mansi to Ankita in UT1 and UT2.
6. Display first 3 records and last three records.
7. Delete the record of Ankita.
8. Write code in python so draw a bar graph between student names and Final mark columns of
the above DataFrame Set the xlabel "Name" and ylabel as "Final Marks" and title as 'Result’.
(ii) To display details of all items in the stock table in ascending order of StockDate. 1
(iii) To display ItemNo and Item name of those items from Stock table whose unit price is more than 10
rupees.
(iv) To display the details of those items whose dealer code(DCode ) is 102 or quantity in stock(Qty) is
more than 100 from the stock table.
(v) To display the maximum UnitPrice of items for each dealer individually as per Dcode from the table
stock.
data = {
df = pd.DataFrame(data, index=students)
first_three = df.head(3)
last_three = df.tail(3)
df.drop('Ankita', inplace=True)
8. Draw a bar graph between student names and Final mark columns
plt.figure(figsize=(10, 6))
plt.xlabel("Name")
plt.ylabel("Final Marks")
plt.title("Result")
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
2)
Item VARCHAR(50),
Dcode INT,
Qty INT,
StockDate DATE
);
GROUP BY Dcode;
Set 2
CREATE the following DataFrame emp
Fname Lname Salary Designation
100 Ravi Kumar 75000 Manager
103 Harry Waltur 65000 Manager
215 Sarah Ackerman 75000 Manager
244 Manila Sengupta 50000 Clerk
300 Robert Samuel 45000 Clerk
Answer the following questions based on the shove DataFrame
1. Add a new row for the employee with index as 167 and values (Arpita. Sharma, 50000, Manager).
2. Change the row label 244 to 567.
3. Display designation of employees with index from 152 to 300.
4. Display designation of Robert.
5. Display last 3 records
6. Add a new column 'column' with values [400, 700, 500, 300, 200, 400, 600,800].
7. Delete the record of Sarah.
8 Write python code to create a Line Graph using Fname and salary columns. Set xlabel as "Name" and
ylabel as "Salary". Title of graph is "Analysis of Salary".
(IV) To display the average price of all the dresses which are made up of material with MCODE as M003.
(V) To display material wise highest and lowest price of dresses from DRESS table.(Display MCODE of
each dress along with highest and lowest price)
(VI) To add a primary key constraint in dcode field,
data = {
designation_152_to_300 = emp.loc[152:300,
'Designation'] print("Designation of employees with
index from 152 to 300:\n",
designation_152_to_300)
emp.drop(emp[emp['Fname'] == 'Sarah'].index,
inplace=True)
plt.figure(figsize=(10, 6))
plt.xlabel("Name")
plt.ylabel("Salary")
plt.title("Analysis of Salary")
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
Q2)
DCODE INT,
DESCRIPTION VARCHAR(50),
LAUNCHDATE DATE
);
GROUP BY MCODE;
data = {
coffee_record = SHOP.loc[103]
3. Display the Item and city for all items from 102 to 103
print("\nItem and city for all items from 102 to 103:\n", item_city_102_to_103)
first_three = SHOP.head(3)
last_three = SHOP.tail(3)’
SHOP.drop(columns=['city'], inplace=True)
plt.figure(figsize=(10, 6))
plt.bar(SHOP['items'],
SHOP['Quantity'], color='skyblue')
plt.xlabel("Items")
plt.ylabel("Quantity")
plt.title("Stock")
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
Q2)
4) UPDATE Employee
5) SELECT dept,
MAX(Salary) AS MaxSalary,
MIN(Salary) AS MinSalary,
AVG(Salary) AS AvgSalary
FROM Employee
GROUP BY dept;
FROM Employee
GROUP BY desig;
Set 4
1. Create the table Product with Pcode as a primary key and insert the given rows in the table. (2)
2. Display the details of the product produced by Apple having quantity more than 50. (1)
3. Display pname, qty, price and company for the products where price is between 30000 to 80000. (1)
4. Display maximum price of products for each company. (1)
5. Display the average price of LED TV . (1)
6. Display the difference between maximum price and minimum price for each company (1)
data = {
DF = pd.DataFrame(data)
4. Display the records of those countries whose growth rate is greater than 18
8. Draw a simple horizontal bar graph using columns COUNTRY and EXPENDITURE
plt.figure(figsize=(10, 6))
plt.xlabel("Expenditure")
plt.ylabel("Countries")
plt.tight_layout() plt.show()