Code No. 065 | Sample Question Paper (Theory)
S1 is created with index labels ['a', 'b', 'c', 'd', 'e']. State whether the following statement is True or False:"The statement S1 ['b':'d'] will produce the same result as S1 [1:3]." S1['b':'d'] includes the stop label 'd' (returns 3 elements: b, c, d), whereas positional slicing S1[1:3] excludes index 3 (returns 2 elements: b, c).StudentName column. Which SQL function should he use? import pandas as pd print(pd.Series(5, index=[0, 1, 2]))
GROUP BY clause based on a specific condition is ____________. ORDER BY clause to sort data in descending order? to_csv() function. He wants to save only the data and avoid writing the row indices to the file. Which parameter should he set to False to prevent the indices from being included? BETWEEN operator is inclusive of both the lower and upper values specified in the range. df.drop('Science', axis=0) will remove the column labeled 'Science' from the DataFrame.axis=0 refers to row-wise operations and axis=1 refers to column-wise operations. axis=1 must be used.select * from emp; and SELECT * FROM EMP; will produce the same result.head() function in a Pandas DataFrame.head() function? head() function returns the first n rows of a DataFrame.df[df['Marks'] > 80]Ename from the EMPLOYEE table.SELECT RIGHT(Ename, 3) FROM EMPLOYEE;SELECT INSTR('Informatics', 'ma');dict1 = {'a': 10, 'b': 20}dict2 = {'a': 5, 'b': 10, 'c': 20}import pandas as pd
dict1 = {'a': 10, 'b': 20}
dict2 = {'a': 5, 'b': 10, 'c': 20}
df = pd.DataFrame([dict1, dict2])read_csv() and explain the use of its sep parameter. read_csv() reads a CSV file into a DataFrame. The sep parameter specifies the delimiter/separator character used in the file (default is comma ,).Inventory from the following dictionary:stock = {'Pens': 150, 'Erasers': 80, 'Sharpeners': 60, 'Notebooks': 200}import pandas as pd S1 = pd.Series([10, 20], index=['a', 'b']) S2 = pd.Series([30, 40], index=['b', 'c'])Write the output of:
print(S1 + S2) import pandas as pd
stock = {'Pens': 150, 'Erasers': 80, 'Sharpeners': 60, 'Notebooks': 200}
Inventory = pd.Series(stock)(ii) Output:a NaN b 50.0 c NaN dtype: float64
df as shown below:
| Index | Name | IP | Maths |
|---|---|---|---|
| 0 | Arpit | 95 | 88 |
| 1 | Vani | 89 | 92 |
| 2 | Chetan | 78 | 80 |
df['Total'] = [183, 181, 158]df.rename(columns={'Name': 'Student'}, inplace=True)df.drop('Maths', axis=1, inplace=True)| PNo | PName | Dept | DOA |
|---|---|---|---|
| 101 | Ravi Kumar | Cardiology | 2024-05-12 |
| 102 | Anita Sharma | Neurology | 2025-06-01 |
| 103 | Mohan Das | Cardiology | 2023-05-18 |
| 104 | Seema Verma | Orthopedics | 2022-04-22 |
| 105 | Rahul Singh | Cardiology | 2025-03-30 |
SELECT LOWER(PName) FROM HOSPITAL WHERE Dept = 'Cardiology';SELECT PNo, DAYNAME(DOA) FROM HOSPITAL;SELECT PName FROM HOSPITAL ORDER BY PName ASC;| ID | Name | DOB |
|---|---|---|
| 1 | Aman | 2005-08-15 |
| 2 | Vinod | 2006-01-26 |
| 3 | Saurabh | 2004-01-01 |
SELECT UPPER(Name), LENGTH(Name) FROM STUDENT WHERE ID = 2;SELECT DAY(DOB), YEAR(DOB) FROM STUDENT WHERE ID = 3;SELECT RIGHT(Name, 3) FROM STUDENT WHERE ID = 1; VINOD | 51 | 2004manSELECT POWER(MOD(13, 5), 2);SELECT UCASE(MID("Digital India", 9, 5));SELECT LENGTH(TRIM(" Informatics ")); 9 (Since 13 % 5 = 3, and 3^2 = 9)INDIA11import matplotlib.pyplot as plt
months = ['Jan', 'Feb', 'Mar', 'Apr']
sales = [12000, 15000, 11000, 18000]
plt.plot(months, sales, label="Sales")
plt.title("Sales Performance")
plt.xlabel("Month")
plt.ylabel("Amount")
plt.legend()
plt.show()| RegNo | SName | Game | Fees |
|---|---|---|---|
| 101 | Aryan | Cricket | 500 |
| 102 | Riya | Tennis | 600 |
| 103 | Kabir | Cricket | 500 |
| 104 | Ishaan | Tennis | 600 |
| 105 | Tejas | Football | 750 |
| CoachID | CName | Game |
|---|---|---|
| C1 | Venkatesh | Cricket |
| C2 | Rameshwar | Tennis |
| C3 | Sridhar | Football |
SELECT Game, SUM(Fees) FROM SPORTS GROUP BY Game HAVING SUM(Fees) > 1000;SELECT SName, CName FROM SPORTS, COACH WHERE SPORTS.Game = COACH.Game;| EmpID | Name | DeptID | Salary |
|---|---|---|---|
| 301 | Aarav | D1 | 5200 |
| 302 | Riya | D2 | 7500 |
| 303 | Kabir | D2 | 6800 |
| 304 | Ananya | D3 | 4000 |
| 305 | Ishaan | D1 | 4900 |
| DeptID | DeptName |
|---|---|
| D1 | HR |
| D2 | IT |
| D3 | Sales |
SELECT DeptID, COUNT(*), MAX(Salary) FROM Employee GROUP BY DeptID HAVING COUNT(*) > 1 ORDER BY DeptID;SELECT Name, DeptName FROM Employee, Department WHERE Employee.DeptID = Department.DeptID AND Employee.Salary > 6000; D1 | 2 | 5200D2 | 2 | 7500Riya | ITKabir | IT| From | To | Distance |
|---|---|---|
| Block A | Block B | 40 m |
| Block A | Block C | 50 m |
| Block A | Block D | 160 m |
| Block B | Block C | 70 m |
| Block B | Block D | 60 m |
| Block C | Block D | 120 m |
| Block | No. of Computers |
|---|---|
| Block A | 25 |
| Block B | 60 |
| Block C | 15 |
| Block D | 150 |
StoreDF as shown below using a dictionary of Series:
| Index | Items | Quantity | Unit_Price |
|---|---|---|---|
| 0 | Bread | 50 | 30 |
| 1 | Milk | 100 | 25 |
| 2 | Eggs | 120 | 6 |
['Butter', 40, 55] at index position 3.import pandas as pd
data = {
'Items': pd.Series(['Bread', 'Milk', 'Eggs']),
'Quantity': pd.Series([50, 100, 120]),
'Unit_Price': pd.Series([30, 25, 6])
}
StoreDF = pd.DataFrame(data)
(ii) StoreDF.loc[3] = ['Butter', 40, 55]print(StoreDF['Items'])| BookID | Title | Author | Price |
|---|---|---|---|
| 201 | Wings of Fire | APJ Abdul Kalam | 350 |
| 202 | The Guide | R. K. Narayan | 299 |
| 203 | The God of Small Things | Arundhati Roy | 399 |
| 204 | Malgudi Days | R. K. Narayan | 280 |
205, 'The White Tiger', 'Aravind Adiga', 350.Publisher of type VARCHAR(30) to the table.BOOK from the database. INSERT INTO BOOK VALUES (205, 'The White Tiger', 'Aravind Adiga', 350);UPDATE BOOK SET Price = 325 WHERE BookID = 202;DELETE FROM BOOK WHERE Author = 'R. K. Narayan';ALTER TABLE BOOK ADD Publisher VARCHAR(30);DROP TABLE BOOK;PCode, PName, Category, Qty, Price, ExpiryDate.SELECT PName, ROUND(Price, 1) FROM PRODUCT;SELECT PName FROM PRODUCT WHERE PName LIKE '%s';SELECT PName, Category FROM PRODUCT WHERE Price <= 500;SELECT SUM(Qty) FROM PRODUCT;SELECT LTRIM(PName) FROM PRODUCT;