Marking Scheme Practical Paper
Marking Scheme Practical Paper
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
b) SQL Queries:
FROM DRUGDB
(iii) SELECT *
FROM DRUGDB
WHERE DrugName LIKE 'C%sh%';
FROM DRUGDB;
# 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:
UPDATE VOTERS
SET Age = 45
FROM VOTERS
GROUP BY Address;
Set C
# 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)
# Adding a new column 'Grade'
df['Grade'] = ['A' if x > 90 else 'B' for x in df['Marks']]
# Changing index
df.index = ['I', 'II', 'III', 'IV', 'V']
# Updating last row's marks to 65
df.loc['V', 'Marks'] = 65
print(df)
FROM PRODUCT;
Write a query to display the name of those customers who have purchased
Mobile and Laptop:
Display Cname, Pname of those customers who have "a" anywhere in their
name:
FROM PRODUCT
SELECT *
FROM PRODUCT;