Half Yearly Examination 2022-23 PT2: Class XII

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

PT2

HALF YEARLY EXAMINATION 2022-23


Class XII INFORMATICS PRACTICES Time: 3 hrs.
Marks: 70
SECTION A - OBJECTIVE TYPE 15 × 1 = 15

1. In boolean indexing ................ can be used to filter the data.

a) Blooean vectors b) boolean column c) boolean mapper d) boolean label

2. While accessing the column from the dataframe, we can specify the column name. In
case column does not exist, which type of error it will raise?

a) Key Error b) Syntax Error c) Name Error d) Runtime Error

3. .................. can be doen either in ascending or descending order.

OR

Pandas DataFrame ................. function converts DataFrame into CSV files.

4. Write the output of the following code:

import pandas as pd

data=pd.DataFrame( )

print(data)

5. Columns can be sorted in descending sequence by using the ............. keyword.

6. What is not true about Data Visualisaiton?

a) Graphical representation of information and data

b) Helps users in analysing a large amount of data in a simpler way

c) Data Visualisation makes complex data more accessible, understandable and usable

d) No library needs to be imported to create charts in Python language

7. What is the minimum number of arguments required for plot( ) function in matplotlib?

a) 1 b) 2 c) 3 d) 4

8. .................. attribute in legend ( ) can be a string specifying the legend location.

9. .................. refers to the tick marks of a plot.

10. Which one indicates the discontinuity?

a) Histogram b) Pie chart c) Bar graph d) None of these

11. Which is a Python package used for 2D graphics?

a) matplotlib.pyplot b) matplotlib.pip

c) matplotlib.numpy d) matplotlib.plt

1
12. State true or false

Grid ( ) method of axes class adds a legend to the plot figure.

13. Give the syntax of the ORDER BY clause. (State True/False)

14. Write a code to create a series object using a dictionary that stores the salary of employees
in ABC organisation.

15. The cardinality property of a relation refers to the

a) number of database b) number of columns

c) number of rows d) number of tables

SECTION B - COMPETEMCY BASED QUESTIONS 4 × 3 = 12

16. Read the statements given below. Identify the right option from the following for attribute and
method/function.

Statement A : Attribute always ends without parenthesis.

Statement B : Function/Method cannot work without arguments.

a) Both statements are correct b) Both statements are incorrect

c) Statement A is correct, but Statement B is incorrect.

d) Statement A is incorrect, but Statement B is correct.

17. Zeenat has created the following data frame dataframel to keep track of data Rollno, Name,
Marks1 and Marks2 for various students of her class where row indexes are taken as the
default values:

Rollno Name Markis1 Marks2

1 Swapnil Sharma 30 50

2 Raj Batra 75 45

3 Bhoomi Singh 82 95

4 Jay Gupta 90 95

i) Which among the following option will give 90, 95 as output?

a) print(max(dataframe1[‘marks1’, ‘Marks2’])

b) print((dataframe1, Marks1.max( ). (dataframe1.Marks2.max( ))))

c) print(max(datafrane1[‘Marks1’]) d) print(max(dataframe1[‘Marks2’])

ii) She needs to know the marks scored by Rollno 2. Help her to identify the correct set of
statement(s) from the given options.

a) print (dataframe1 [dataframe1[‘Rollno’] = =2])

b) print(dataframe1 [‘Rollno’] = =2)

2 IP + 2 (PT-2)
c) print(dataframe1[dataframe1. Rollno = = 2])

d) print (dataframe1[dataframe1 [‘Rollno’]])

iii) Which of the following statement(s) will delete the 3rd column?

A. del dataframe1[‘Marks1’] B. dataframe1.pop(‘Marks1’)

C. drop dataframe1[‘Marks1’} D. pop dataframe1[‘Marks1’]

Choose the correct option.

a) Both A and B b) Only B c) A, B and C d) A, B and D

iv) Which of the following command will display the total number of elements in the dataframe?

a) print(dataframe1.shape) b) print(dataframe1.num)

c) print(dataframe1.size) d) print(dataframe1.elements)

v) Now she wants to add a new column “Marks3” with relevant data. Help her to choose the
command to perform this task.

a) dataframe1.column = [ 45, 52, 90, 95] b) dataframe1 [‘Marks3’] = [ 45, 52, 90, 95]

c) dataframe1.loc [‘Marks3”] = [ 45, 52, 90, 95]

d) Both (b) and (c)

18. A Gift Gallery has different stores in India. Database Administrator Abhay wants to maintain
database of their Salesmen in SQL to store the data. He has decided that

Name of the database GiftGallery

Name of the table Salesman

Attributes of the table Scode - Numeric, Sname - Character 25, Address - Character 25,
Dofjoin-Date, Sales - Numeric and Area - Character 10.

Consider the following records in ‘Salesman’ table and answer the given questions.

Table : Salesman

Scode Sname Address Dofjoin Sales Area

100 Sushant Delhi 2017/09/29 5000.90 East

101 Sushant Gurgaon 2018/01/01 7000.75 East

102 Priya Noida 2018/04/25 3450.45 West

103 Mohit Delhi 2018/11/03 6000.50 North

104 Priyanshi Delhi 2019/12/15 8000.62 North

3 IP + 2 (PT-2)
i) State the command that will give the output as

Sname

Sushant

Priya

a) SELECT Sname FROM Salesman WHERE NOT address = “Delhi”;

b) SELECT Sname FROM Salesman WHERE Address NOT IN (“Delhi”);

c) SELECT Sname FROM Salesman WHERE Address !=”Delhi”;

d) All of the above

ii) Which of the following commands will display the details of all sales record of North Area,
regardless of case (whether North / NORTH / north).

a) SELECT * FROM Salesman WHERE Area LIKE UPPER ‘North’;

b) SELECT * FROM Salesman WHERE Area = North’ or ‘NORTH’ or north;

c) SELECT * FROM Salesman WHERE upper (area) = ‘NORTH’;

d) SELECT * FROM Salesman WHERE Area= = upper “North”;

iii) Help Priya to display sname and sales of east and west areas.

a) SELECT Sname, Sales FROM Salesman WHERE Area = “East” AND Area = “West”;
b) SELECT Sname, Sales FROM Salesman WHERE Area = “East” OR Area = “West”;
c) SELECT Sname, Sales FROM Salesman WHERE Area IN “East” AND “West”;

d) SELECT Sname, Sales FROM Salesman WHERE Area = “East”, “West”;

iv) The command to display the name of the salesman along with the sales amount rounded
off to one decimal point will be:

a) SELECT Sname, ROUND(sales, 1) FROM Salesman;

b) SELECT Sname, ROUND(sales, 0, 1) FROM Salesman;

c) SELECT Sname, TRUNC(sales, 1) FROM Salesman;

d) SELECT Sname, TRUNC(sales, 0, 1) FROM Salesman;

19. Read the statements given below and identify the right option to draw a histogram.

Statement A : To make a histogram with matplotlib, we can use the plt.hist( ) function.

Statement B : The bins parameter is compulsory to create histogram

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 C - SHORT & LONG ANSWER
20. What is matplotlib? 2
4 IP + 2 (PT-2)
21. Write a code to plot a bar chart to depict the pass percentage of students in CBSE exams for
the years 2015 to 2018 as shown below. 2

22. Write a Python code to create a DataFrame with appropriate headings from the list given
below:

[‘S101’, ‘Amy’, 70], [‘S102’, ‘Bandhi’, 69], [‘S104’, ‘Cathy’, 75], [‘S105’, ‘Gundaho’, 82] 2

23. How to create a Series from lists? 2

OR

Differentiate between Series and DataFrame.

24. Write the output of the following code 3

import pandas as pd

data = {‘a’ : pd. Series ([20, 85, 46, 23, 56], index = [1, 2, 3, 4, 5]), ‘b’ : pd. Series ([33, 45, 57,
12, 34, 82, 49], index = [1, 2, 3, 4, 5, 6, 7])}

df = pd. DataFrame (data)

print (df)

OR

Consider the series object srl that stores the salary of teacher, as shown below. Here Teacher’s
name represents by their initial names.

R 15000

K 12000

N 20000

L 22000

Write the code to modify the salary of K as 18000 and for N and L as 25000. Print the changed
Series.

25. Mention the type of the functions given below with their purpose. 3

i) CHAR( ) ii) TRUNCATE( ) ii) DAYOFMONTH( ) iv) LEFT ( )

26. Draw the approximate graph which display the multiline in same plot. 3

import matplotlib.pyplot as plt

x1 = [10, 20, 40]


5 IP + 2 (PT-2)
y1 = [20, 50, 10]

plt.plot(x1, y1, label = “line 1”)

x2 = [10, 20, 30]

y2 = [40, 10, 20]

plt.plot(x2, y2, label = “line 2”)

plt.xlabel (‘x - axis’)

plt.ylabel (‘y - axis’)

plt.title (‘Multiline’)

plt.legend ( )

plt.show( )

27. Define the following terms:

i) Line chart ii) grid ( ) function 3

28. Write the code for the following graph which display the different style multiline in same plot.

29. A bat graph is used to show individual figures at a specific time or to compare different items.
Similarly, a bar graph which is showing the marks of different subjects. You have to write the
code that will represent the given graph. 5

30. Write a pandas program to sort the DataFrame first by Name in descending order, then by
‘Score’ in ascending order. 5

Sample DataFrame :

6 IP + 2 (PT-2)
exan_data ={‘Name’, ‘Chirag’, ‘Tarun’,

‘Anjali’, ‘Mahi’, ‘Tushar’, ‘Shubham’, ‘Harsh’,

‘Vanshika’, ‘Kartik’]

Score’; [12, 5, 9, 16, 5, np.NaN, 9, 20, 14, 5, np.NaN, 8, 19],

‘Attempts’ : [1, 3, 2, 3, 2, 3, 1, 1, 2, 1],

‘Qualify’ : [‘Yes’, ‘No’, ‘Yes’, ‘No’, ‘No’, ‘Yes’, ‘Yes’, ‘No’, ‘No’, ‘Yes’]}

labels=[‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’, ‘j’]

31. Explain the features of Python Pandas. 5

32. Write a code to create the following DataFrame

RNo. Name Marks 5

SecA 21 Abhi 69.5

SecB 45 Anjali 84.5

SecC 23 Tushar 70.0

SecD 17 Mahi 78.0

Write the commands to do the following operations on the DataFrame given above:

i) ‘To add new section SecE with the values [08, ‘Kushal’, 80.0].

ii) To modify the marks of SecC to 68.5.

7 IP + 2 (PT-2)

You might also like