Page 1
HALF YEARLY EXAMINATION
Question Paper
2022-23
NCERT BASED SYLLABUS
FOR CBSE AND STATE BOARD
FOLLOWING NCERT
Page 2
QUESTION PAPER
PT-
PT-2/HALF YEARLY EXAMINATION, 2022-
2022-23
INFORMATICS PRACTICES
Time - 7:15 AM to 10:20 AM Class - XII M.M. : 70
Date – 07.09.2022 (Wednesday)
Name of the student _________________________________________________ Section _____
General Instructions:
• Please read the instructions carefully.
• This Question Paper consists of 36 questions in
four sections – Section A, B, C & D.
• Section A contains 11 MCQ type questions of 1
mark and 5 questions of 2 marks each.
• Section B contains 13 questions of 2 marks each.
• Section C contains 5 Short Answer type questions
of 3 marks each.
• Section D contains 2 questions of 4 marks each.
• All questions of a particular section must be
attempted in the correct order.
SECTION- A
MULTIPLE CHOICE QUESTIONS. [1x11=11]
Q.1 To get the transpose of a dataframe DF, you can write _____
a. DF.Transpose b. DF.Swap c. DF.T d. [DF].T
Q.2 To display third element of a Series object S, you will write _____
a. S[:3] b. S[2] c. S[3] d. S[:2]
Q.3 To get a number representing number of axes in a dataframe _______ attribute may be used.
a. size b. shape c. values d. ndim
Q.4 If a dataframe is created using 2D dictionary, then the column labels are formed from _____
a. dictionary’s values b. inner dictionary’s keys
c. outer dictionary’s keys d. none of these
Q.5 To change the 5th column’s values at 3rd row as 44 in dataframe df, you can write ______
a. DF[4,6]=44 b. DF[3,5]=44 c. DF.iat[4,6]=44 d. df.iat[3,5]=44
Q.6 The argument which will write NULL inplace of NaN values in CSV file is:
a. rep= “NULL” b. narep= “NULL” c. na_rep= “NULL” d. rep_na= “NULL”
Q.7 While creating DataFrame using CSV, to specify our own column name we use ______
argument.
a. name b. column c. columns d. names
Q.8 Which argument must be set with ploting functions for legends() to display the legends?
a. data b. label c. name d. sequence
PT-2 / HALF YEARLY EXAM | INFORMATICS PRACTICES | CLASS 12 | 2022-23 | PRINTED Q 36 PRINTED PAGES 7 | PAGE# 1
Page 3
Q.9 Which argument in hist() is used to create a stacked bar type histogram?
a. histt b. histtype c. type d. barstacked
Q.10 Which of the below given task cannot be performed through Data Manipulation Language
(DML) commands?
a. Create table in the database b. Insert a record in a table.
c. Delete a record from a table. d. Modify a record into a table.
Q.11 What will be returned by the following query?
SELECT MONTH(‘2022-11-09’);
a. 9 b. 11 c. November d. September
MULTIPLE CHOICE QUESTIONS. [2x5=10]
Q.12 Ahna has written the following code to create a dataframe with boolean index:
import numpy as np
import pandas as pd
df=pd.DataFrame(data=[5,6,7]], index=[true,false,true])
print(df)
While executing this code, she is getting an error, help her to rectify the code, from the
options given below.
a) df=pd.DataFrame([True,False,True], data=[5,6,7])
b) df=pd.DataFrame(data=[5,6,7], index=[True,False,True])
c) df=pd.DataFrame([true,false,true], data=[[5,6,7]])
d) df=pd.DataFrame(index=[true,false,true],data=[[5,6,7]])
Q.13 Consider the following statements:
Statement A: .loc() is a label based data selecting method to selec a specific row(s) or
column(s) which we want to select .
Statement B: .iloc() can not be used with default indices if customised indices are provided.
Select the correct option.
a) Statement A is true, but Statement B is false.
b) Statement A is false, but Statement B is true.
c) Statement A and Statement B both are false.
d) Statement A and Statement B both are true.
Q.14 ___________ and _______ functions help you to iterate over a DataFrame.
Q.15 To suppress first row as header, which of the following argument is to be given in
read_csv()?
a) noheader=True b) header=None c) skipheader=True d) header=Null
PT-2 / HALF YEARLY EXAM | INFORMATICS PRACTICES | CLASS 12 | 2022-23 | PRINTED Q 36 PRINTED PAGES 7 | PAGE# 2
Page 4
Q.16 Consider the following statements with reference to Line Chart:
Statement A: Line chart is tool for comparison and is created by plotting a series of several
points and connecting them with a straight line.
Statement B: You should always use Line Chart when the chart is in a continuous data set.
a) Statement A is correct.
b) Statement B is correct.
c) Statement A is correct but Statement B is incorrect.
d) Statement A is incorrect but Statement B is correct.
SECTION - B
OBJECTIVE QUESTIONS: [2x7=14]
Q.17 DataFrame is ________ mutable as well as ________ mutable.
Q.18 The _______ argument of plot() specifies the style of the line and the ______ function is used to
specify ticks for x-axis.
Q.19 One word answer:
a) Which function is used to create a histogram?
b) Which command is used to give heading of the graph?
Q.20 True or False:
a) The number of rows in a dataframe are by default equal to number of rows in CSV file, it
created from a CSV file.
b) CSV file can only store comma separated values.
Q.21 What will be returned by the following query?
select truncate(215.79, -1), truncate(215.79,1);
Q.22 What will be returned by the following query?
select instr(‘INDIA’,’DI’), substr(‘INDIA’,-4,3);
Q.23 Display output of the following functions:
a) SELECT DAYOFWEEK(NOW());
b) SELECT DAY(‘2022-09-07’);
SUBJECTIVE QUESTIONS: [2x6=12]
Q.24 Given:
import pandas as pd
d={‘one’:pd.Series([1.,2.,3.], index=[‘a’, ‘b’, ‘c’]), ‘two’: pd.Series([1.,2.,3.,4.], index=[‘a’, ‘b’, ‘c’,
‘d’])}
df1=pd.DataFrame(d, index=[‘d’, ‘b’, ‘a’])
df2=pd.DataFrame(d,index = [‘d’, ‘a’], columns= [‘’two’, ‘three’])
print(df1)
print(df2)
What will the above code display ?
PT-2 / HALF YEARLY EXAM | INFORMATICS PRACTICES | CLASS 12 | 2022-23 | PRINTED Q 36 PRINTED PAGES 7 | PAGE# 3
Page 5
Q.25 Predict the output from the following MySQL statements:
a) SELECT ROUND(28.34), ROUND(32.76);
b) SELECT ROUND(28.38,1), ROUND(32.76, -1);
Q.26 Given a DataFrame ‘DF’ as follows:
Yr1 Yr2 Yr3
Qtr1 34500 44900 54500
Qtr2 56000 46100 51000
Qtr3 47000 57000 34900
Qtr4 78000 76960 67830
Write appropriate python coding to extract the data from DF, row wise.
Q.27 Given a dataframe df1 as follows:
1990 2000 2010
A 52 340 898
B 64 480 560
C 78 688 1102
D 94 766 889
Write Python code to create a line chart from the columns, 1990 and 2000.
Q.28 Create a bar chart plotting the three columns of the above given (refer Q.No. 26) dataframe
df1.
Q.29 Write a program to read from sports.csv file(shown below and location of the file is
“c:\data”) where the separator is a tab character.
Sports.csv:
Sport Competition Prizes won
Tennis 14 9
Football 22 16
Chess 25 15
SECTION - C
Answer the following questions: [3x5=15]
Q.30 Give Python code to create the following DataFrame “Batsman” from a Dictionary:
B_No Name Score1 Score2
1 Sunil Pillai 90 80
2 Gaurav Sharma 65 45
3 Nilesh Kumar 78 100
4 Abhishek Tiwari 89 45
Perform the following operations on the DataFrame:
(i) Add both the scores of a batsman and assign to column “Total”
(ii) Display the highest score in both Score1 and Score2.
(iii) Display the DataFrame.
PT-2 / HALF YEARLY EXAM | INFORMATICS PRACTICES | CLASS 12 | 2022-23 | PRINTED Q 36 PRINTED PAGES 7 | PAGE# 4
Page 6
Q.31 If Ser is a series object having 30 values, then how are statements (i),(ii) and (iii) similar
and different?
(i) print(Ser.head()) (ii) print(Ser.head(8)) (iii) print(Ser.tail(11))
OR
(i) Write a program to create a Series object S1 using a dictionary that stores the number of
students in section of class 12 as per the following data:
A 56
B 67
C 34
D 43
E 50
(ii) Write Python statement to arrange the records of the series S1 in descending order.
(iii)Write a Python statement to display the data where more than 50 students are studying.
Q.33 Consider the following database table Students given below:
ADMN NAME CLS SEC RN ADDRESS PHONE
1211 MEENA 12 D 4 A-26 3245678
1212 VANI 10 D 1 B-25 5456789
1213 MEENA 12 A 1 NULL NULL
1214 KARISH 10 B 3 AB-234 4567890
1215 SURAJ 11 C 2 ZW12 4345677
Write MySQL statements for the following:
(i) To extract the three characters starting from second position from the Name column.
(ii) To display the First letter of each name in capital letters and rest all the characters in
lowercase.
(iii) To combine the Address with Name of the students and display.
Q.33 Write MySQL statements for the following tasks:
(i) Truncate the value 213.899 to two decimal places.
(ii) Round off the value 453.495 to two decimal places.
(iii) Find out the sign of the value -756;
Q.34 Write MySQL statements for the following tasks:
(i) Consider a field birth_date in EMPL table which stores the date of birth of an employee.
Write a MySQL statement to calculate the approximate age of employees in terms of
years.
(ii) Using the same field name birth_date of EMPL table, write appropriate MySQL
statement which display the output in the following manner( if employee smith’s
birth_date is 1995-12-02 and his name is stored in the field Ename):
“Smith is born in the month of December”
(iii) Write MySQL statement to obtain the number of days passed in the current year.
PT-2 / HALF YEARLY EXAM | INFORMATICS PRACTICES | CLASS 12 | 2022-23 | PRINTED Q 36 PRINTED PAGES 7 | PAGE# 5
Page 7
SECTION - D
Answer the following questions: [4x2=8]
Q.35 Nitika is the activity incharge in a school. One of her student gave her an idea to use Python
Pandas and Matplotlib for analysing and visualising the data respectively. She has created a
DtatFrame “AnnualDay” to keep track of the number of First, Second and Third prizes won
by different houses in various events.
House First Second Third
0 Nehru 5 8 3
1 Raman 3 5 7
2 Azad 6 2 5
3 Sarojini 5 3 2
4 Ramanujan 4 6 5
5 Tagore 3 8 2
Write Python command to do the following:
(i) Display the house names where the numbers of Second prizes are in the range of 5 to 8.
(ii) Display all the records in reverse order.
(iii) Display the output of the following statement.
X=df.columns[:1]
print(X)
(iv) Write Python statement which counts the total data i.e. 24.
Q.36 Consider the code given below (all required libraries are imported) and the output
produced by it and answer the following questions:
(i) Why is the chart showing one bar only while we are plotting four values on the chart?
a=[3,6,9,12]
b=[30,48,54,48]
plt.xlim(-3,5)
plt.bar(a,b)
plt.show()
PT-2 / HALF YEARLY EXAM | INFORMATICS PRACTICES | CLASS 12 | 2022-23 | PRINTED Q 36 PRINTED PAGES 7 | PAGE# 6
Page 8
(ii) What changes will you make to the code of previous question so that the bars are
visible for all four points as shown below? But do keep in mind that the x-axis must
begin from the point -3.
OR
Consider the database table salesman:
SNO SNAME Salary Bonus Date_of_Join
A01 Beena Mehta 30000 45.23 2019-10-29
A02 K. L. Sahay 50000 25.34 2018-03-13
B03 Nisha Thakkar 30000 35.00 2017-03-18
B04 Leela Yadav 80000 Null 2018-12-31
C05 Gautam Gupta 20000 Null 1989-01-23
C06 Tripti Garg 70000 12.37 1987-06-15
D07 Neena Sharma 50000 27.89 1999-03-18
Write MySQL statement for the following:
(i) Display salesman name and bonus after rounding off to zero decimal places.
(ii) Display the position of occurrence of the string “ta” in the salesman name.
(iii) Display the name of the day for the date of join of salesman.
(iv) Display the four characters from the salesman name starting from second character.
PT-2 / HALF YEARLY EXAM
AglaSem | INFORMATICS
Earn whilePRACTICES
Learn | CLASS 12 | 2022-23 | PRINTED
Program. SendQ 36
papers andPRINTED
getPAGES
your 7 | PAGE# 7
paid.
Contact: support@