0% found this document useful (0 votes)
132 views

Cbse Class 12 Informatics Practices Term1 Solved Question Paper 2022

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views

Cbse Class 12 Informatics Practices Term1 Solved Question Paper 2022

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

CBSE Class 12

Informatics practices
Previous Year Question Paper 2022 - Term 1
Series: SSK/3 SET - 4
Q.P. Code 090
i. Please check that this question paper contains 16 printed pages.
ii. Please check that this question paper contains 55 multiple choice
questions (MCQs).
iii. Q.P. Code given on the right hand side of the question paper should be
written on the appropriate place of the OMR Sheet by the candidates.
iv. 20 minutes additional time has been allotted to read the question paper
prior to actual time of commencement of examination.

Informatics Practices
(Term – I)
Time allowed : 90 minutes Maximum
Marks : 35

General Instructions:
i. This question paper is divided into 3 Sections - A, B and C.
ii. Section - A consists of Questions 1 to 25. Students need to attempt 20
questions.
iii. Section - B consists of Questions 26 to 49. Students need to attempt 20
questions.
iv. Section C consists of Questions 50 to 55. Students need to attempt 5
questions.
v. All questions carry equal marks.

SECTION-A
Section A consists of 25 questions. Attempt any 20 questions.
1. Which of the following statements is wrong?

Class XII Informatics Practices www.vedantu.com 1


a. Can't change the index of the Series.
b. We can easily convert the list, tuple, and dictionary into a series
c. A Series represents a single column in memory.
d. We can create an empty Series.
Ans: List, Tuple & dictionary can easily be converted into series using
pd.Series(list or tuple or dictionary ). A single column in memory
means a series of 1d arrays which is valid. We can create an empty series with
just executing pd.Series( ).It is possible to change the index of the series even
after creation. Hence, the correct option is ‘a’.
2. What type of error is returned by the following statement?
import pandas as pa
pa. Series ([1,2,3,4], index = ['a', 'b', 'c'])

a. Value Error b. Syntax Error

c. Name Error d. Logical error

Ans: In the following statement, We are creating a series of 4 values but the
index is only 3 (a,b,c) which should be equal to the size of the series. So, it
will give a Value Error. the correct statement will be pa. Series ([1,2,3,4],
index = ['a', 'b', 'c', ‘d’]). Hence, the correct option is ‘a’.
3. Which is incorrect statement for the python package Numpy?
a. It is a general-purpose array-processing package.
b. Numpy arrays are faster and more compact
c. It is multi-dimensional arrays
d. It is proprietary software
Ans: Numpy is not a proprietary software. It is an open-source software and
has many contributors. you can use it freely by just importing into
your project using the syntax import numpy. Hence, the correct option
is ‘d’.
4. The data of any CSV file can be shown in which of the following
software?

Class XII Informatics Practices www.vedantu.com 2


a. MS Word
b. Notepad
c. Spreadsheet
d. All of the above
Ans: A CSV (Comma Separated Value) file is a text file in which information
is separated by comma and can be opened in any program. All of the software
which is given in option use to open CSV file. Hence, the correct option is ‘d’.
5. Which python library is not used for data science?

a. Panda b. Numpy

c. Matplotlib d. Tkinter

Ans: Pandas, Numpy & matplotlib all of this library is used for data science
if assuming panda is a typographical error of pandas.Tkinter is a python
framework which is used to create GUIs(Graphical User Interface)
application. Hence, the correct option is ‘d’.
6.Which method is used to Delete row(s) from Data Frame?

a. .drop() method b. .del() method

c. .remove() method d. .delete() method

Ans: .drop( ) method is used to delete row(s) and column(s) from


DataFrame.row, column can be deleted using index label or column name by
using this method. Hence, the correct option is ‘a’.
7.Consider the following code:
import numpy as np
import pandas as pd
L=np.array ([10,20])
X=pd. Series (_______) #statement 1
print (x)
output of the above code is:

Class XII Informatics Practices www.vedantu.com 3


0 1000
1 8000
d type: int64
What is the correct statement for the above output in the following
statement 1?

a. d=L*3 b. data=L**3

c. L*3 d. [10,20]**3

Ans: 1000 and 8000 are the cube of 10 and 20 respectively. Finding the cube
of L array will give the 1000 of 10 and 8000 of 20. L **3 will find the cube of
each element of the array and return the cubed array. Hence, the correct option
is ‘b’.
8.Which library is imported to draw charts in Python?.

a. csv b. matplotlib

c. numpy d. pandas

Ans: Matplotlib library in Python imported to draw charts. csv is not a library,
numpy is a python library used to working with arrays, pandas is also a python
library which is used for data manipulation and analysis. Hence, the correct
option is ‘b’.
9.Which of the following would give the same output as DF/DF1 where
DF and DF1 are DataFrames.

a. DF.div(DF1) b. DF1.div(DF)

c. Divide(DF,DF1) d. Div(DF,DF1)

Ans: Syntax of dividing two dataFrame is


divisionResults = dataFrame1.div(dataFrame2) where dataFrame1 is
componendo and dataFrame2 is dividend. Hence, the correct option is ‘a’.
10. Which of the following statements is wrong in the context of Data
Frame?

Class XII Informatics Practices www.vedantu.com 4


a. Two-dimensional size is Mutable.
b. Can Perform Arithmetic operations on rows and columns.
c. Homogeneous tabular data structure
d. Create Dataframe from numpy ndarray
Ans: dataFrame is a two-dimensional mutable data structure that can store
heterogeneous data in tabular format which can perform arithmetic operations
on rows and columns. Hence, the correct option is ‘c’.
11. Which attributes are not used with Data Frame?

a. size b. type

c. empty d. columns

Ans: size, empty,columns all are these are the attributes of dataFrame. type is
not an attribute and doesn’t exist in the dataframe. Hence, the correct option is
‘b’.
12. With the outset of Covid-19 schools started online classes but
continuous online classes students’ health issues also started. The
practitioner advised the parents to follow a few health tips. Which
following health tip should not be suggested?
a. The sitting posture should be correct
b. Breaks should be taken in between the online classes.
c. To protect the eyes the gadgets should be placed above eye level.
d. Wash the eyes regularly.
Ans: To Protect the eye, gadgets should not be placed above the eye. It should
be at a straight level or below your eyes.Sitting posture, break in between the
online classes and washing the eyes regularly are all health tips. Hence, the
correct option is ‘c’.
13. The following is automatically granted to the creator or owner of any
invention.

a. Patent b. Copyright

Class XII Informatics Practices www.vedantu.com 5


c. Trademark d. License

Ans: copyright is a type of intellectual property which protects original work


of ownership. it is automatically granted to the creator or owner of any
invention. Patent, Trademark and License follow a legal process to be granted.
Hence, the correct option is ‘b’.
14. Himanshi sets up her own company to sell her own range of
clothes on instagram. What type of intellectual property can she use to
show that the clothes are made by his company?

a. Patent b. Copyright

c. Design d. Trademark

Ans: Trademarks are used to show that the product is made by which
company. which distinguishes you from others from other competitors. Hence,
the correct option is ‘d’.
15. GPL stands for?

a. Guided Public License b. General Public License

c. Global Public License d. General Public letter

Ans: GPL – general Public License. Hence, the correct option is ‘b’.
16. E- waste is becoming one of the fastest growing environmental
hazards in the world today. If it is not properly treated or disposed of it can
cause serious health hazards, therefore The ______ has issued a formal set
of guidelines for proper handling and disposal of e-waste.
a. Central Pollution Control Board (CPCB)
b. Department of Information Technology (DIT)
c. Electrical and Electronic Equipment (WEEE)
d. Information Communication Technology (ICT)
Ans: CPCB manages environmental data statistics and conducts environmental
assessment research in India. They have issued a formal set of guidelines for
proper handling and disposal of e-waste. Hence, the correct option is ‘a’.

Class XII Informatics Practices www.vedantu.com 6


17. When we create a data Frame from a list of Dictionaries the
column labels are formed by the
a. Union of the keys of the dictionaries
b. Intersection of the keys of the dictionaries
c. Union of the values of the dictionaries
d. Intersection of the value of the dictionaries
Ans: To create the pandas dataFrame, we can pass the list of dictionaries as
input data. The column names are formed as keys of the dictionary by Default.
Hence, the correct option is ‘a’.
18. To change the width of bars in a bar chart, which of the following
arguments with a float value is used?

a. hwidth b. width

c. breath d. barwidth

Ans: ‘width’ is a property used to change the width of bars in a bar chart.
Hence, the correct option is ‘b’.
19. Identify the correct option to select first four rows and second
columns from a DataFrame 'Data'

a. display(Data.iloc[1: 4, 2:4]) b. display(Data.iloc[1: 5, 2:5])

c. print(Data.iloc[0: 4, 1:4]) d. print(Data.iloc[l: 4, 2:4])

Ans: Data.iloc[0: 4, 1:4] is the correct option to select the first four rows and
second columns because indexing starts with 0(zero). Hence, the correct option
is ‘c’.
20. Which of the following commands is used to import matplotlib
for coding?

a. import matplotlib.pyplot as plt b. import plt.matplotlib as plt

c. import py.matplotlib as plt d. import pyplot.matplotlib as plt

Class XII Informatics Practices www.vedantu.com 7


Ans: import matplotlib.pyplot as plt command is used to import matplotlib
for coding. Hence the correct option is ‘a’.
21. Consider the following statements with reference to Line charts
Statement - A Line graph is a tool for comparison and is created by
plotting a series of several points and connecting them with a straight
line.
Statement – B You should never use line charts 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
Ans: A Line graph is a tool for comparison and is created by plotting a series
of several points and connecting them with a straight line is a correct statement
but statement B is incorrect because line chart can be used when the chart is in
a continuous data set. Hence, The correct option is ‘c’.
22. What is not true about Data Visualization?
a. Graphical representation of information and data
b. Helps users in analyzing a large amount of data in simpler way
c. Data visualization makes complex data more accessible,
understandable and usable.
d. No library needs to be imported to create charts in python
language.
Ans: Data Visualization is a graphical representation of information of data
which makes complex and large amounts of data more easy to understand. The
Matplotlib library needs to be imported to create charts in Python language.
Hence, the correct option is ‘d’.
23. Which attribute is used with Series to count the total number of NaN
values.

a. size b. len

Class XII Informatics Practices www.vedantu.com 8


c. count d. count total

Ans: In options, len and count are methods not an attribute. count total is not
an attribute or method, it’s a invalid option. Size is an attribute which is used
with a series to count the total number of NaN values. Hence, the correct
option is ‘a’.
24. Consider the following Series in Python :
data = pd.Series([5, 2, 3,7], index=['a', 'b', 'c', 'd'])
Which statement will display all odd values

a.print(data%2==0) b. print(data(data%2!=0))

c. print(data mod 2!=0) d. print(data[data%2!=0])

Ans: data [ data % 2 != 0] is the correct syntax to print all odd values. Firstly
data % 2 != 0 gives the Boolean result of the series which value is odd or not.
data [ data % 2 != 0] will print the all odd values of the series. Hence, the
correct option is ‘d’.
25. Priya is a student of class 10 and she is a very frequent user of
internet applications. One day she got an unpleasant message on her
instant messenger. What do you think she should do?
a. Start chatting with an unknown person.
b. talk to her parents/teacher or other trusted adult and let them know
that she is feeling uncomfortable.
c. Ignore the conversation.
d. She should delete the chat so that no one comes to know
Ans: Talk to her parent/teacher or other trusted adult and let them know that
she is feeling uncomfortable is the correct decision for the following situation.
Hence, the correct option is ‘b’.
SECTION – B
Section B consists of 24 questions (26-49). Attempt any 20 questions
26. What will be the output of the following code?

Class XII Informatics Practices www.vedantu.com 9


import pandas as pd
import numpy
S=pd.series(data=[31,54,34,89,12,23],dtype=numpy.int) print(s>50)
a. b. c. d.

0 False 1 54 0 31 1 True
1 True 3 89 1 54 3 True
2 False dtype: int64. 3 89 dtype: bool
3 True 4 12
4 False 5 23
5 False dtype: int64
dtype: bool
Ans: s>50 checks every element of the series with condition individually and
returns a bool type i.e. either True or False26. for each one of them. Hence, the
correct option is ‘a’.
27. The primary law in India dealing with cybercrime and
electronic commerce is?
a. India’s Technology ( IT ) Act, 2008
b. India’s Digital Information Technology (DIT) Act, 2000
c. India’s Information Technology (IT) Act, 2000
d. The Technology Act, 2008
Ans: The Information Technology Act, 2000 (also known as ITA-2000, or the
IT Act) is an Act of the Indian Parliament notified on 17 October 2000 ,
dealing with cybercrime and electronic commerce. Hence, the correct option is
‘c’.
28. Consider the following statement with reference to Trademark
and Hacking
Statement 1: Trademark is a document that provides legally binding
guidelines for the use and distribution of software.

Class XII Informatics Practices www.vedantu.com 10


Statement 2: Hacking is the act of unauthorized access to a computer
network or any digital system.
a. Statement 1 is True but Statement 2 is False
b. Statement 1 is False but Statement 2 is True
c. Both the statements are True
d. Both the statements are False
Ans: Software License provides legally binding guidelines for use and
distribution for software and Hacking is the act of unauthorized access to a
computer network or any digital system. Hence, the correct option is ‘b’.
29. Consider a following DataFrame :
import pandas as pd
s = pd.Series(data = [31,54,34,89,12,23]
df = pd.dataFrame ( s )
Which statement will be used to get the output as 2 ?

a. print(df.index( )) b. print(df.dhape( ))

c. print(df.ndim( )) d. print(df.values( ))

Ans: ndim returns dimensionality. It returns 1 if df is Series otherwise returns


2 if df is Dataframe.Here df is a data frame so if we run or execute
print(df.ndim( )) command output will give 2 Hence, the correct option is ‘c’.
30. Sandhya wants to display the last four rows of the dataframe df and
she has written the following command:
df.tail( )
But the first 5 rows are being displayed. To rectify this problem, which
of the following statements should be written ?

a. df.head( ) b. df.last(4)

c. df.tail(4) d. df.rows(4)

Class XII Informatics Practices www.vedantu.com 11


Ans:head(n) returns first n rows of data and tail(n) returns last n rows of data,
default value is 5. df.tail(4) will return last 4 rows of data. Hence, the
correct option is ‘c’.
31. There is only 1 day left for Ravisha to submit her science
project. Therefore she performed the following activities to complete
her task. Which of the following activities can be considered as
plagiarism ?
a. Downloaded the image that were marked as CC and pasted in her
project file.
b. Copied the content from some website and pasted in her life.
c. Copied the content from the website and gave references about
the same in the project.
d. Downloaded and installed the open source software for typing the
synopsis.

Ans: plagiarism is the act of copying another person’s ideas, words or work
and pretending they are your own without acknowledgement. Hence, the
correct option is ‘b’.
32. A contract between the creator and the user to allow the user
use his/her work with some price is

a. Agreement b. Copyright

c. License d. Patent

Ans: This type of contracts are called License, which allows one party to use
another one's material for generating revenue by giving a fixed amount or
percentage of profits. Hence, the correct option is ‘c’.
33. Consider the following series
Ser = pd.Series( [ ‘C’, ‘O’, ‘M’, ‘F’, ‘O’, ‘R’, ‘T’, ‘A’, ‘B’, ‘L’, ‘E’],
index = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
print (ser [4 : ] )

Class XII Informatics Practices www.vedantu.com 12


a. b. c. d.

4 F 4 F 4 F 5 O
5 O 5 O 5 O 6 R
6 R 6 R 6 R 7 T
7 T 7 T 7 T 8 A
8 A 8 A 8 A 9 B
9 B 9 B 10 L
dtype: object
10 L 11 E
dtype: Object
11 E
dtype: Object
dtype: Object

Ans: s[x:] returns elements from index x+1 to last index , it excludes index x.
print (ser [4 : ] ) will print index 5 to last index. Hence, the correct option is
‘d’.
a. Nowadays for developing Machine Learning projects programmers
rely on CSV files rather than databases. Why ?
b. csv can be used with proprietary softwares only.
c. csv files can be downloaded from open-source websites free of cost.
d. csv files need not be imported while creating the projects.
e. csv is a simple and well formatted mode for data storage.
Ans: csv files are simple and easy storage for data whereas databases are very
big and heavy software. Hence, the correct option is ‘d’.
35. Companies get their Trademark registered to protect ?
a. logos, names and brand
b. word, phrase or symbol
c. slogans, stylized fonts and colors

Class XII Informatics Practices www.vedantu.com 13


d. company furniture, worker, brands
Ans: Trademark is a legally registered property consisting of sign, design and
words that represents a company or brand. Hence, the correct option is
‘a’.
36. Dataframes can be created from ?

a. lists b. dictionaries

c. series d. all of the above

Ans: Dataframe can be created from lists, series, dictionaries. Hence, the
correct option is ‘d’.
37. Rohit forgot his laptop in his car and when he came back he found
his laptop was missing. This act is

a. Cyber crime b. Phishing


c. Theft d. Plagiarism

Ans: Theft is an act of stealing someone else’s property, taking someone’s


laptop from their car without consent is an act of stealing/theft. Hence, the
correct option is ‘c’.
38. Consider the following statements
Statement A : .loc( ) is a label based data selecting method to select a
specific row(s) or column(s) which we want to select.
Statement B : .iloc( ) can not be used with default indices if customized
indices are provided.
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
Ans: .loc() is a label based data selecting method to select specific rows or
columns and .iloc() can be used with customized indices. Hence, the correct
option is ‘a’.

Class XII Informatics Practices www.vedantu.com 14


39. Abhay is a student of class ‘XII’ and he is aware of some concepts of
python. He has created the DataFrame, but he is getting errors after
executing the code. Help him by identifying the correct statement that will
create the DataFrame:
Code:
import pandas as pd
stuname = {‘Muskan’, Radhika’, ‘Gopar’, ‘Pihu’}
term1 = [70, 63, 74, 90]
term2 = [67, 70, 86, 95]
a. df = pd.DataFrame({“Name”:stuname, “marks1”:term1,
“marks2”:term2})
b. df = pd.DataFrame([stuname,term1,term2], columns =
[‘stuName’,”marks1”, “marks2”])
c. df = pd.DataFrame({stuname,term1,term2})
d. df = pd.dataframe({stuname,term1,term2})
Ans: Dataframe can be created from dictionary.In the first option
{“Name”:stuname, “marks1”:term1, “marks2”:term2} is a dictionary
which can be easily converted in dataframe using the command
pd.DataFrame( ). Hence, the correct option is ‘a’.
40. Ms. Kalpana is working with an IT company, and she wants to create
charts from the data provided to her.
She generates the following graph :

Class XII Informatics Practices www.vedantu.com 15


Which statement is used to mark the line as given in the above fig. :
a. plt.plot(x,y, marker=’#’, markersize=10, color=’red’,
linestyle=’dashdot’)
b. plt.plot(x,y, marker=’star’, markersize=10, color = ‘red’)
c. plt.plot(x,y, marker=’@’, markersize = 10, color=’red’,
linestyle=’dashdot’)
d. plt.plot(x,y, marker=’*’, markersize = 10, color = ‘red’)
Ans: Marker attribute of a pyplot is used to emphasize each point in the plot
with a given specific marker. Hence, the correct option is ‘d’.
41. Mr. Raman created a DataFrame from a Numpy array :
arr = np.array([[2, 4, 8], [3, 9, 27], [4, 16, 64] ] )
df = pd.DataFrame( arr, index = [‘one’, ‘two’, ‘three’], ____ )
print ( df )
Help him to add a customized column labels to the above DataFrame
a. columns = ‘no’, ‘sq’, ‘cube’

Class XII Informatics Practices www.vedantu.com 16


b. column = [‘no, ‘sq’, ‘cube’]
c. columns = [‘no’, ‘sq’, ‘cube’]
d. columns = [[‘no’, ‘sq’, ‘cube’]]
Ans: columns parameter is used to provide customized column labels in the
dataframe. It will take a value from 0 to n-1, If the column name is not defined
by default. Hence, the correct option is ‘c’
42. What will be the output of the following program import pandas as
pd
dic = {‘Name’ : [‘Sapna’, ‘Anmol’, ‘Rishul’, ‘Sameep’], ‘Agg’ : [56,
67, 75, 76] , ‘Age’: [16, 18, 16, 19]}
df = pd.DataFrame( dic, columns = [‘Name’, ‘Age’])
print( df )

a.

Name Agg Age


101 Sapna 56 16
102 Anmol 67 18
103 Rishul 75 16
104 Sameep 76 19

b.

Name Agg Age


0 Sapna 56 16
1 Anmol 67 18
2 Rishul 75 16
3 Sameep 76 19
c.

Class XII Informatics Practices www.vedantu.com 17


Name
0 Sapna
1 Anmol
2 Rishul
3 Sameep
d.
Name Age
0 Sapna 16
1 Anmol 18
2 Rishul 16
3 Sameep 19

Ans: columns parameter can be used to select specified columns,it can also be
used to provide customized column labels in the dataframe. If the column
name is not defined by default. In this question, columns are Name and Age
given so the name and age column with index will print. Hence, the correct
option is ‘d’.
43. Consider the following code
import pandas as pd
S1 = pd.Series([23,24,35,56], index = [‘a’, ‘b’, ‘c’, ‘d’])
S2 = pd.Series([27,12,14,15], index = [‘b’, ’y’, ‘c’, ‘ab’])
df = pd.DataGrame(S1 + S2)
print(df)
Output for the above code will be

Class XII Informatics Practices www.vedantu.com 18


a. O
a NaN
ab Nan
b 51.0
c 49.0
d NaN
y NaN

b. O
a 50
b 36
c 49
d 71

c. O
b 50
y 36
c 49
ab 71

d. O
a NaN
ab NaN
b NaN
c NaN
d NaN

Class XII Informatics Practices www.vedantu.com 19


y NaN

Ans: when two Series objects are added together , then missing values are
filled with NaN if column is not present in both objects and if values are
present in both objects then value is calculated and replaced with new value.
Hence, the correct option is ‘a’.
44. Sudhanshu 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 the code, she is getting an error, help her to
rectify the code :
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]] )
Ans: In python, ‘true’ and ‘false’ are not defined keywords, ‘True’ and ‘False’
are defined keywords T and F of True and False are in uppercase. Hence, the
correct option is ‘b’.
45. The rights of the owner of information to decide how much
information is to be shared/exchanged/distributed, are collectively known
as ________.

a. Intelligent Portable Rights b. Intellectual Property Rights

Class XII Informatics Practices www.vedantu.com 20


c. Interactive Property Rights d. Instance Portability Rights

Ans: The rights of the owner of the information to decide how much
information is to be exchanged, shared or distributed are called Intellectual
property rights. Hence, the correct option is ‘c’.
46. Abhilasha forgot to sign out from her gmail id and Aditi used
Abhilasha’s gmail id to send mail. This act of Aditi is Considered as

a. Plagiarism b. Identity Theft

c. Phishing d. Digital Activity

Ans: Identity theft is using someone else's personal identifying information to


pretend to be them without their consent. Hence, the correct option is ‘b’.
47. The trail that is automatically created when a person use the internet
on any digital device like Laptops, smart phones, tablets etc is called

a. Cyberbullying b. Phishing

c. Digital Footprint d. Digital Activity

Ans: Digital Footprint is the data that is left behind when someone uses
internet for any kind of activity through any digital electronic device such as
smartphone, laptop, Computer etc. Hence, the correct option is ‘c’.
48. _______ operating system comes under FOSS.

a. Windows b.Ubuntu

c. Mac d.Oracle

Ans: FOSS refers to Free and Open Source Software. Oracle Solaris is
completely open source and Free, that is why it comes under FOSS, while
Ubuntu, Microsoft and Mac are privately owned and their source codes are not
available to everyone. Hence, the correct option is ‘d’.
49. Sushila has created a DataFrame with the help of the following code;
import pandas

Class XII Informatics Practices www.vedantu.com 21


EMP = {EMPID': ['E01 E02, E03", "E04', 'E05'],
'EMPNAME’ : [‘KISHORI’, ‘PRIYA', 'DAMODAR',
'REEMA', ‘MANOJ’],
'EMP SALARY’: [67000,34000,68000,90000,43000]
}
df = pandas.DataFrame(EMP, index=['001', '002','003', '004','005'])
print(df.loc[0:3,:])
and she wants to get the following output

EMPID EMPNAME EMP SALARY


001 E01 KISHORI 67000
002 E02 PRIYA 34000
003 E03 DAMODAR 68000
Help her to correct the code

a. print(df.iloc[‘001’:’003’, :]) b. print(df.iloc[‘001’: ‘003’, :])

c. print(EMP[loc[0:3,:]]) d. print(df.loc[‘001’:’004’,:])

Ans: column names are in string format ( ‘001’ ) that is why when trying to
access it we have to reference it as it is not as integers. Hence, the correct
option is ‘b’.

SECTION - C
Section C consists of 6 questions( 50 – 55 ). Attempt any 5 questions
Case Study
Ms Ramdeep Kaur maintains the records of all students of her class. She
wants to perform some operations on the data:
Code:
import pandas as pd

Class XII Informatics Practices www.vedantu.com 22


t = { ‘Rollno’ : [101, 102, 103, 104, 105, 106, 107],
‘Name’ : [‘Shubrato’, ‘Krishna’, ‘Pranshu’, ‘Gurpeet’, ‘Arpit’,
‘Sanidhya’, ‘Aurobindo’],
‘Age’: [15, 14, 14, 15, 16, 15, 16],
‘Marks’: [77.9, 70.4, 60.9, 80.3, 86.5, 67.7, 85.0],
‘Grade’ : [‘11B’, 11A’, ‘11B’, ‘11C’, ‘11E’, ‘11A’, ‘11C’]}
df = pd.DataFrame(t, index = [10, 20, 30, 40, 50, 60, 70])
print(df)
Output of the above code :

Roll no Name Age Marks Grade


10 101 Shubrato 15 77.9 11B
20 102 Krishna 14 70.4 11A
30 103 Pranshu 14 60.9 11B
40 104 Gurpreet 15 80.3 11C
50 105 Arpit 16 86.5 11E
60 106 Sanidhya 15 67.7 11A
70 107 Aurobindo 16 85.0 11C

Based on the given information, answer question No. 50 – 55.


50. Select the correct statement for the below output
Name Krishna
Age 14
Marks 70.4
Grade 11A

Class XII Informatics Practices www.vedantu.com 23


Name:20, dtype: object

a. print(df.iloc[2]) b. print(df.loc[2])

c. print(df.iloc[20]) d. print(df.loc[20])

Ans: loc[x] access a group of rows and columns by label(s) or a boolean


array.basically, loc[n] returns data at index n. Hence, the correct option is ‘d’.
51. The teacher wants to know the marks secured by the second last
student. Only which
statement would help her to get the correct answer ?

a. print (df.loc[60:70,’Marks’]) b. print(df.loc[60:60, ‘Marks’])

c. print(df.iloc[-2:-2],[Marks’]) d. print( df[-2:-2][‘Marks’])

Ans: df.loc[60:60,’Marks’] returns value at index 60 only of column Marks,


which is the
second last marks student. Hence, the correct option is ‘b’.
52. Which of the following statement(s) will add a new column ‘fee’ at
second position
with values [3200, 3400, 4500, 3100, 3200, 4000, 3700] in DataFrame
df?
a. df.insert(loc=2, column='fee’, value= [3200, 3400,
4500,3100,3200,4000, 3700]
b. df.add(2,column=’fee’,value = [3200, 3400, 4500, 3100, 3200, 4000,
3700])
c. df.append(loc=2,’fee’ = [3200, 3400, 4500, 3100, 3200, 4000, 3700]
d. df.insert(loc=2, ‘fee’,[3200, 3400, 4500, 3100, 3200, 4000, 3700])
Ans: Insert is a method of data frame class that allows the user to add a new
column at any given position in a dataframe or series. Hence, the correct
option is ‘a’.

Class XII Informatics Practices www.vedantu.com 24


53. Which of the following commands is used to delete the column
‘Grade’ in the dataFrame df ?
a. df.drop(‘Grade’, axis = 1, inplace=True)
b. df.drop(‘Grade’, axis = 0, inplace=True)
c. df.drop[‘Grade’, axis = 1, inplace= True]
d. df.delete(‘Grade’, axis=1,inplace=True)
Ans: pandas drop method is used to drop or remove a given column or row
from dataframe. by specifying the column axis, the drop() method removes the
specified column and by specifying the row axis, the drop() method removes
the specified row. Hence, the correct option is ‘a’.
54. Which of the following commands would rename the column ‘Marks’
to ‘Halfyearly’ in the DataFrame df ?
a. df.rename([‘Marks’,’Half Yearly’], inplace= True)
b. df.rename({‘Marks’,’Halfyearly’}, inplace=True)
c. df.rename(columns = {‘Marks’:’halfyearly’}, inplace= True)
d. df.rename([‘Marks’:’Halfyearly’], inplace=True)
Ans: rename is a method of dataframe class that can be used to rename an
existing column with a new name. Hence, the correct option is ‘c’.
55. Which of the following commands will display the Names and Marks
of all students getting more than 80 marks ?
a. print(df.loc[‘Marks’ > 80,[‘Name’,’Marks’]])
b. print(df.loc[df[‘Marks’] <80,‘Name’,’Marks’])
c. print(df.loc[df[‘Marks’] < 80,[‘Name’,’Marks’]])
d. print(df.loc[df[‘Marks’] > 80,[‘Name’,’Marks’]])
Ans: df[‘Marks’]>80 returns True only if the value is greater than 80 in the
Marks column, and loc method accepts a Boolean array and returns the value
only if array element is True. Hence, the correct option is ‘d’.

Class XII Informatics Practices www.vedantu.com 25

You might also like