Marking scheme practical paper (2)
Marking scheme practical paper (2)
Set A
Q1. Answer Key
import pandas as pd
serObj['May'] = 31
serObj['Feb'] = 29
serObj.index = [1, 2, 3, 4, 5]
iv) Command to print a month name having number of days less than 31:
v) Output:
1 False
2 True
3 False
4 True
5 False
dtype: bool
b) print(serObj + 3):
1 34
2 32
3 34
4 33
5 34
dtype: int64
Q2. Python Program to Display a Bar Chart
# Data
groups = ['I', 'II', 'III', 'IV']
strength = [38, 30, 45, 49]
# Display chart
plt.show()
b) SQL Queries:
UPDATE DRUGDB
SET Price = Price + 35
WHERE DrugName = 'Paracetamol';
(ii) To display the DrugID, RxID, and PharmacyName in descending order of their
price:
(iii) Display all details of the drugs where name starts with ‘C’ and has ‘sh’
somewhere in the name:
SELECT *
FROM DRUGDB
WHERE DrugName LIKE 'C%sh%';
(iv) Display the drug name in lower case along with price rounded off to the nearest
integer:
# Data
groups = ['I', 'II', 'III', 'IV']
strength = [38, 30, 45, 49]
# Creating DataFrame
data = {
'Product Name': ['Moisturiser', 'Sanitizer', 'Bath Soap', 'Shampoo', 'Lens Solution',
'Bath Soap'],
'Manufacture': ['XYZ', 'LAC', 'COP', 'TAP', 'COP', 'TQR'],
'Price': [40, 35, 25, 95, 350, 500]
} df = pd.DataFrame(data)
# Save to CSV
df.to_csv('products.csv', index=False)
To list Vno, Vname, Age for all the voters sorted by Age:
SELECT *
FROM VOTERS
WHERE Address = 'Guwahati';
Display Vname, Vno of those voters who have "N" at the start of their name:
To list voters where address is "Delhi" but age between 20 and 30:
SELECT *
FROM VOTERS
WHERE Address = 'Delhi' AND Age BETWEEN 20 AND 30;
To delete the records of all those voters who are either residing in "Delhi" or
whose Age > 35:
UPDATE VOTERS
SET Age = 45
WHERE Vname LIKE '%Kumar%';
# Creating DataFrame
data = {
'Rno': [10, 20, 30, 40, 50],
'Name': ['Raj', 'Ajay', 'Minu', 'Tina', 'Akash'],
'Subject': ['Maths', 'Science', 'Maths', 'SST', 'SST'],
'Marks': [88, 99, 55, 66, 77]
}
df = pd.DataFrame(data)
# Changing index
df.index = ['I', 'II', 'III', 'IV', 'V']
print(df)
UPDATE PRODUCT
SET Price = 10000
WHERE Pname = 'Cooler' AND Price = 5000;
SELECT *
FROM PRODUCT;