QP Xii Ip Hy 2024-25
QP Xii Ip Hy 2024-25
SECTION-A(1 MARKS)
1 Difference between loc() and iloc().: 1
a. Both are Label indexed based functions.
b. Both are Integer position-based functions.
c. loc() is label based function and iloc() integer position based function.
d. loc() is integer position based function and iloc() index position based function
2 Which function will be used to write data to a CSV file into pandas data frame? 1
a. readcsv() b. to_csv() c. read_csv() d. csv_read()
3 What is the minimum number of arguments required for plot() function in matplotlib? 1
a. 1 b. 2 c. 3 d. 4
1
d. None of Above
SELECT LENGTH(“WIN.NER”);
a. 7 b. 6
c. 8 d. 9
8 If column FEES in a table STUDENT contains the data set (5000, 8000, NULL, 5000, 8000) what will be 1
the output after execution of the given query?
a. 8000 b. 8004
c. 8005 d. error
9 All aggregate functions except_____________ ignore null values in their input collection. 1
a. Count(attribute) b. Count(*)
c. Avg d. Sum
10 Given the following Series. Write the output.
1
import pandas as pd1
s = pd1.Series([1,2,3,4,5],index = ['a','b','c','d','e'])
print (s[-3:])
a. c 3 b. a 1
d 4 b 2
e 5 dtype: int64
dtype: int64
c. a 1 d. None of these
b 2
c 3
dtype: int64
2
12 Using Python Matplotlib _________ can be used to count how many values fall into each interval 1
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
18 Assertion (A): While accessing values of Pandas Series using slices, the values at the start and end 1
index can be also included.
Reason (R):In Pandas Series slicing using labelled index display all the values from starting to end
index.
SECTION-B(2 MARKS)
3
19 2
20 Rashmi, a database administrator needs to display house wise total number of records of ‘Red’ and 2
‘Yellow’ house. She is encountering an error while executing the following query
SELECT HOUSE, COUNT (*) FROM STUDENT GROUP BY HOUSE
WHERE HOUSE=’RED’ OR HOUSE= ‘YELLOW’;
Help her in identifying the reason of the error and write the correct query by suggesting the possible
correction (s).
21 What is the purpose of WHERE clause in SQL? How it is different from having clause? Explain with the 2
help of suitable example.
22 Write a program to create a series object using a dictionary that stores the number of students in each 2
house of class 12B of your school.
Note: Assume four house names are Beas, Chenab, Ravi and Satluj having 18, 2, 20, 18 students
respectively and pandas library has been imported as pd.
23. The python code written below has syntactical errors. Rewrite the correct code and underline the 2
corrections made.
Import pandas as pd
Monument=['Qutub Minar','Gateway of India','Red Fort','Taj Mahal']
State=['Delhi','Maharashtra','Delhi','Uttar Pradesh']
S=Pd.series(Monument,index=State)
Print(s)
4
25 a) Fill in the blanks: 2
import __________ as pd
Year1={'L1':5000,'L2':8000,'L3':12000,'L4': 18000}
Year2={'X' :13000,'Y':14000,'Z':12000}
totSales={1:Year1,2:Year2}
df=_______.DataFrame(________)
print(df)
SECTION-C(3 MARKS)
26 Write outputs for SQL queries (i) to (iii) which are based on the given table SCHOOL: 3
Or
27 Write a Python code to create a DataFrame with appropriate column headings from the list given 3
below:
[[101,'AMIT',98],[102,'RAJVEER',95],[103,'SAMAR' ,96], [104,'YUVI',88]]
ii. 3
SECTION-D(5 MARKS)
31 Consider a table Teacher with the following data: 5
6
Write SQL queries using SQL functions to perform the following operations:
b) Display the position of first occurrence of the string “a” in all values under Names column.
c) Display the four characters, starting from second character from all values in Department column.
OR
7
Give proper labels and write a command to save figure
OR
SECTION-E(4 MARKS)
34 4
8
A. Predict the output of the following python statement:
i. df.columns
ii. df.iloc[1:3,1:]
B. Write Python statement to add a new column ACC_NO
(with values as – [135,153,225,442])
C. Write Python statement to export the DataFrame to a CSV file named data.csv stored at D:
drive.