0% found this document useful (0 votes)
76 views22 pages

12 - Ip - MCQ Term-I-1

This document discusses Python Pandas library and its core data structure Series. It contains questions about Pandas, NumPy, key features of Series like index, data types. Questions cover topics like creating Series from different data types, basic operations on Series and important functions.

Uploaded by

Abhi Chauhan
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)
76 views22 pages

12 - Ip - MCQ Term-I-1

This document discusses Python Pandas library and its core data structure Series. It contains questions about Pandas, NumPy, key features of Series like index, data types. Questions cover topics like creating Series from different data types, basic operations on Series and important functions.

Uploaded by

Abhi Chauhan
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/ 22

Python Pandas:-Series d.

Brendan Eich
Q1. Which of the following is/ are libraries in
Q10. A is a one-dimensional array.
Python?
a. Data Frame
a. NumPy
b. Series
b. Pandas
c. Both of the above
c. Matplotlib
d. None of the above
d. All of the above
Q11. Which of the following statement is wrong?
Q2. Which of the following libraries allow to
a. We can create Series from Dictionary in Python.
manipulate, transform and visualize data easily
b. Keys of dictionary become index of the series.
and efficiently?
c. Order of indexes created from Keys may not be
a. Pandas
in the same order as typed in dictionary.
b. NumPy
d. All are correct
c. Matplotlib
Q12. A Series by default have numeric data labels
d. All of the above
starting from .
Q3. Minimum number of arguments, we require to
a. 3
pass in pandas series?
b. 2
a. 0
c. 1
b. 1
d. 0
c. 2
Q13. Result of an operation between unaligned
d. 3
Series will have of indexes involved.
Q4. PANDAS stands for
a. intersection
a. Panel Data Analysis
b. union
b. Panel Data analyst
c. total
c. Panel Data
d. all of the mentioned
d. Panel Dashboard
Q14. The data label associated with a particular
Q5. is an important library used for
value of Series is called its
analysing data.
a. Data value
a. Math
b. Index
b. Random
c. Value
c. Pandas
d. None of the above
d. None of the above
Q15. Which of the following module is to be
Q6. We can analyze the data in pandas with:
imported to create Series?
a. Series
a. NumPy
b. DataFrame
b. Pandas
c. Both of the above
c. Matplotlib
d. None of the above
d. None of the above
Q7. Important data structure of pandas is/are
Q16. Which of the following function help to create
a. Series Series?
b. Data Frame a. series( )
c. Both of the above b. Series( )
d. None of the above c. createSeries( )
Q8. Which of the following command is used to d. None of the above
install pandas? Q17. Write the output of the following :
a. pip install pandas import pandas as pd
b. install pandas series1 = pd.Series([40,50,60])
c. pip pandas print(series1)
d. None of the above a.
Q9. Python pandas was developed by? 0 40
a. Guido van Rossum 1 50
b. Travis Oliphant 2 60
c. Wes McKinney dtype: int64

1|K VS – Re gion al Of fice , JAIP UR | Se ss ion 2 02 1 - 22


b. b.
40 a 14
50 dtype: int64
60 c. Error
dtype: int64 d. None of the above
c. Q24. Write the output of the following:
0 S1=pd.Series(14, 7, index = ['a', 'b', 'c'])
1 print(S1)
2 a.
dtype: int64 a 14
d. None of the above b7
Q18. When you display any series then the left c7
most column is showing value. dtype: int64
a. Index b.
b. Data a 14
c. Value b7
d. None of the above dtype: int64
Q19. How many values will be there in array1, if c. Error
given code is not returning any error? d. None of the above
series4 = pd.Series(array1, index = [“Jan”, “Feb”, Q25. Write the output of the following:
“Mar”, “Apr”]) S1=pd.Series([14, 7, 9] ,index = range(1, 8, 3))
a. 1 print(S1)
b. 2 a.
c. 3 14 1
d. 4 7 4
Q20. Which of the following statement will create 9 7
an empty series named “S1”? dtype: int64
a. S1 = pd.Series(None) b.
b. S1 = pd.Series( ) 1 14
c. Both of the above 47
d. None of the above 79
Q21. How many elements will be there in the series dtype: int64
named “S1”? c. Error
>>> S1 = pd.Series(range(5)) d. None of the above
>>> print(S1) Q26. Which of the following code will generate the
a. 5 following output?
b. 4 Jan 31
c. 6 Feb 28
d. None of the above Mar 31
Q22. When we create a series from dictionary then dtype: int64
the keys of dictionary become a.
a. Index of the series import pandas as pd
b. Value of the series S1 = pd.Series(data = [31,28,31],
c. Caption of the series index=["Jan","Feb","Mar"])
d. None of the series print(S1)
Q23. Write the output of the following : b.
S1=pd.Series(14, index = ['a', 'b', 'c']) import pandas as pd
print(S1) S1 = pd.Series([31,28,31],
a. index=["Jan","Feb","Mar"])
a 14 print(S1)
b 14 c. Both of the above
c 14 d. None of the above
dtype: int64
2|K VS – Re gion al Of fice , JAIP UR | Se ss ion 2 02 1 - 22
Q27. Write the output of the following: d.
import pandas as pd 0 31
S1 = pd.Series(data = range(31, 2, -6), index 12
= [x for x in "aeiou" ]) 2 -6
print(S1) 3 31
a. 42
a 31 5 -6
e 25 dtype: int64
i 19 Q30. We can imagine a Pandas Series as a
o 13 in a spread sheet
u7 a. Column
dtype: int64 b. Cell
b. c. Table
a 31 d. None of the above
e 25
i 19
o 13 Answer Key:
dtype: int64 Q. No. Ans Q. No. Ans
c. Error 1 d 16 b
d. None of the above 2 d 17 a
Q28. What type of error is returned by following 3 b 18 a
code? 4 c 19 d
import pandas as pd 5 c 20 c
S1 = pd.Series(data = (31, 2, -6), 6 c 21 a
index = [7, 9, 3, 2]) 7 c 22 a
print(S1) 8 a 23 a
a. SyntaxError 9 c 24 c
b. IndexError 10 b 25 b
c. ValueError 11 d 26 c
d. None of the above 12 d 27 a
13 b 28 c
Q29. Write the output of the following:
14 b 29 d
import pandas as pd
15 b 30 a
S1 = pd.Series(data = 2*(31, 2, -6))
print(S1)
a.
0 31
12
2 -6
dtype: int64
b.
0 31
12
2 -6
3 31
42
dtype: int64
c.
0 31
12
2 -6
3 31
dtype: int64
3|K VS – Re gion al Of fice , JAIP UR | Se ss ion 2 02 1 - 22
Python Pandas:-Series
Q31. Write the output of the following: Q36. Write the statement to get NewDelhi as
import pandas as pd output using positional index.
series2 = pd.Series([“Kavi”,”Shyam”,”Ravi”], import pandas as pd
index=[3,5,1]) S1 = pd.Series(['NewDelhi', 'WashingtonDC',
print(series2 > “S”) 'London', 'Paris'],
a. index=['India', 'USA', 'UK', 'France'])
3 False a. print(S1[0])
5 False b. print(S1[‘India’])
1 False c. Both of the above
dtype: bool d. print(S1.India)
b.
3 False Q37. We can access elements in Series by using
5 True index and index.
1 False a. Numeric, labelled
dtype: bool b. Positional, Naming
c. c. Positional, labelled
3 True d. None of the above
5 True
1 True Q38. Write the output of the following:
dtype: bool import pandas as pd
d. None of the above S1 = pd.Series(['NewDelhi', 'WashingtonDC',
Q32. Which of the following statement is correct 'London', 'Paris'],
for importing pandas in python? index=['India', 'USA', 'UK', 'France'])
a. import pandas print(S1['India', 'UK'])
b. import pandas as pd a.
c. import pandas as pds India NewDelhi
d. All of the above UK London
dtype: object
Q33. What type of error is returned by following b.
statement? India NewDelhi
import pandas as pnd UK Washington
pnd.Series([1,2,3,4], index = [‘a’,’b’,’c’]) dtype: object
a. SyntaxError c. Error
b. IndexError d. None of the above
c. ValueError
d. None of the above Q39. Which of the following statement will print
Series ‘S1’ in reverse order?
Q34. Which attribute is used to give user defined a. print(S1[: : 1]
labels in Series? b. print(S1[: : -1]
a. index c. print(S1[-1: : 1]
b. data d. print(S1.reverse( ))
c. values Q40. How many values will be modified by last
d. None of the above statement of given code?
Q35. Fill in the blank to get the output as 3. import pandas as pd
import pandas as pnd S1 = pd.Series(['NewDelhi', 'WashingtonDC',
S1=pnd.Series([1,2,3,4], index = ['a','b','c','d']) 'London', 'Paris'],
print(S1[ ]) index=['A', 'B', 'C', 'D'])
a. ‘c’ S1['A' : 'C'] = 'ND'
b.2 a. 1
c. c b. 2
d. All of the above c. 3
d. 4
4|K VS – Re gion al Of fice , JAIP UR | Se ss ion 2 02 1 - 22
S2=pd.Series([7,8])
Q41. How many values will be modified by last S3=S1+S2
statement of given code? print(S3.size)
import pandas as pd a. 2
S1 = pd.Series(['NewDelhi', 'WashingtonDC', b. 4
'London', 'Paris'], c. 6
index=['A', 'B', 'C', 'D']) d. Error
S1[1 : 3] = 'ND'
a. 1 Q48. Which of the following statement shows first
b. 2 five values of Series ‘S1’?
c. 3 a. S1.head( )
d. 4 b. S1.head( 5 )
c. Both of the above
Q42. Which of the following attribute assign name d. None of the above
to the Series?
a. name Q49. Write the output of the following:
b. index.name import pandas as pd
c. size S1=pd.Series([1,2,3,4])
d. Series.name S2=pd.Series([7,8])
print((S1+S2).count())
Q43. Which of the following attribute return total a. 6
number of values in Series ‘S1’? b. 4
a. size c. 2
b. values d. 0
c. index
d. None of the above Q50. Which of the following returns number of
non-NaN values of Series?
Q44. Which of the following attributes returns a. count
True if there is no value in Series? b. size
a. index c. index
b. size d. values
c. empty Q51. Write the output of the following:
d. values import pandas as pd
S1=pd.Series([1,2,3,4])
Q45. Which of the following attributes returns all S2=pd.Series([7,8,9,10])
the values of Series? S2.index=['a','b','c','d']
a. size print((S1+S2).count())
b. index a. 8
c. name b. 4
d. values c. 0
d. 6
Q46. Write the output of the following code: Q52. We can perform _ on two series in
import pandas as pd Pandas.
S1=pd.Series() a. Addition
print(pd.Series().empty) b. Subtraction
a. True c. Multiplication
b. False d. All of the above
c. Error Q53. Which of the following method is used to add
d. None of the above two series?
a. sum( )
Q47. Write the output of the following code: b. addition( )
import pandas as pd c. add( )
S1=pd.Series([1,2,3,4]) d. None of the above
5|K VS – Re gion al Of fice , JAIP UR | Se ss ion 2 02 1 - 22
Answer Key:-
Q54. Mathematical Operations on two Series object Q. No. Ans Q. No. Ans
is done by matching 31 b 46 a
a. indexes 32 d 47 b
b. values 33 c 48 c
c. Both of the above 34 a 49 c
d. None of the above 35 d 50 a
36 a 51 c
Q55. Which of following statement will display 37 c 52 d
values more than 40 from Series ‘S1’? 38 c 53 c
a. >>>S1 39 b 54 a
b. >>> S1 > 40 40 c 55 c
c. >>>S1[S1 > 40] 41 b 56 b
d. None of the above 42 a 57 d
43 a 58 b
44 c 59 d
Q56. Which of following statement will return 10
45 d 60 b
values from the end of the Series ‘S1’?
a. S1.tail( )
b. S1.tail(10)
c. S1.head(10)
d. S1(10)

Q57. Which of the following are valid operations on


Series ‘S1’?
a. >>> S1 + 2
b. >>> S1 ** 2
c. >>> S1 * 2
d. All of the above

Q58. When an operation is carried out on every


value of Series object is called
a. Scalar Operation
b. Vector Operation
c. Both of the above
d. None of the above

Q59. Which of the following statement will modify


the first three values of Series ‘S1’?
a. S1[0, 1, 2] = 100
b. S1[0 : 3] = 100
c. S1[ : 3] = 100
d. All of the above

Q60. Following two statements will provide the


same output.
>>>L1 * 2 #L1 is a list
>>>S1 * 2 #S1 is a Series
a. True
b. False

6|K VS – Re gion al Of fice , JAIP UR | Se ss ion 2 02 1 - 22


Extra Questions
Q1. Which of the following function/method Q8. What type of error is returned by
help to create Series? following statement?
a) series( ) import pandas as pd
b) Series( ) s=pd.Series([1,2,3,4], index = [“a”,“b”,“c”])
c) createSeries( ) print(s)
d) None of the above a) Syntax Error
Q2. To get the number of elements in a Series b) Index Error
object , attributes may be used. c) Value Error
a) index d) None of the above
b) size Q9. Way to install the pandas library?
c) itemsize a) Install pandas
d) ndim b) Pandas install python
Q3. Missing data in pandas is represented c) Python install pandas
through: d) None of above
a) NaN Q10. Which of the following attributes returns
b) None all the values of Series?
c) Null a) size
d) Missing b) index
Q4. What will ne the output of the above given c) name
code? d) values
import pandas as pd Q11. Write the output of the following code:
s=pd.Series([1,2,3,4,5],index=["ajay", import pandas as pd
"pankaj","deepti","rajesh","ritika"]) S1=pd.Series()
print(s["rajesh"]) print(pd.Series().empty)
a) 1 a) True
b) 2 b) False
c) 3 c) Error
d) 4 d) None of the above
Q5 Which of the following statement will create Q12. Write the output of the following code :
an empty series named “S1”? import pandas as pd
a) S1 = pd.Series(None) S1=pd.Series([1,2,3,4])
b) S1 = pd.Series( ) S2=pd.Series([7,8])
c) Both of the above S3=S1+S2
d) None of the above
print(S3.size)
Q6. To display the first four rows of a Series
a) 2
object ,you may write
a) head() b) 4
b) tail() c) 6
c) head(4) d) Error
d) tail(4)
Q7. Write the output of the following : Q13. Which of the following returns number of
S1=pd.Series(14, index = ['a', 'b', 'c']) non-NaN values of Series?
print(S1) a) count
a) b) size
a 14 c) index
b 14 d) values
c 14
dtype: int64 Q14. What will be the output for the following
b) code:
a 14 import pandas as pd
dtype: int64 fst=[9,10,11]
c) Error ser1=pd.Series(data=fst*2)
d) None of the above print(ser1)
7|KVS – Regio nal Offi ce , JAIP UR | Ses sio n 2021 - 22
a) 0 9 3 15
1 10 5 15
2 11 b) 1 15
3 9 2 15
3 15
4 10
4 15
5 11 5 15
b) 0 18 c) Error
1 20 b) None of the above
2 22 Q21. To display the fourth element of a Series
object Ser1, you will write
c) Error a) Ser1[2]
d) None of these b) Ser1[3]
Q15. Mathematical Operations on two Series c) Ser1[4]
object is done by matching ____________ d) Ser1[:3]
a) indexes Q22. Mr.Anuj wanted to access multiple index
b) values value from series S1.Which of the following
c) Both of the above statement is correct for him?
d) None of the above a) S1.index[0,1,2,3,4]
Q16. When an operation is carried out on every b) S1.index(0,1,2,3,4)
value of Series object is called: c) S1[0,1,2,3,4]
a) Scalar Operation d) S1[[0,1,2,3,4]]
b) Vector Operation Q23. What will be the output for the following
c) Both of the above code:
d) None of the above import pandas as pd
Q17. Which of the following statement is wrong? S=pd.Series([55,20,10,45,50])
a) We can create Series from Dictionary for i in range (S.size):
in Python. if S[i]>15:
b) Keys of dictionary become index of the print(S[i],end=“ ”)
series. a) 55 20 45 50
c) Order of indexes created from Keys b) 20 45 50 55
may not be in the same order as typed c) 50 35 20 55
in dictionary. d) Error
d) d. All are correct Q24. While creating a series in which of the
Q18. Which of the following statement sort the following way you must need to specifies
Series S1 values in descending order the index?
a) S1.sort_values() a) Using a sequence
b) S1.sort_values(ascending=False) b) Using Dictionary
c) S1.sort_values(ascending=True) c) Using ndArray
d) S1.sort() d) With a scalar value
Q19. Which of the following is true? Q25. Pandas in mainly used for
a) If data is an ndarray, index must be the a) Data Analysis
same length as data. b) Data visualization
b) Series is a one-dimensional labeled c) Data Backup
array capable of holding any data type. d) Data Recovery
c) Both A and B Answer Key:-
d) None of the above 1 2 3 4 5 6 7 8 9 10
b b a d c c a c d d
Q20. Write the output of the following code: 11 12 13 14 15 16 17 18 19 20
import pandas as pd a b a a a b d b c a
Ser2=pd.Series(15,index=range(1,6,2)) 21 22 23 24 25
Print(Ser2) b d a d a
a) 1 15
8 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2
Python Pandas :: DataFrame Q9) Assertion – DataFrame is a two-
DATAFRAME CREATION dimensional Pandas structure, with ordered
Q1) In Python Pandas, which function is used collections of columns that can store data of
to create a dataframe ? different types.
a) createDF() b) dataframe() Reason - Dataframe is an array-like structure with
c) DataFrame() d) Dataframe() two indices or axes – row index ( axis = 0)
and column index (axis=1). Dataframe is value-
Q2) Complete the following code – mutable as well as size- mutable with
#missing statement heterogeneous data.
D = {'code' : [102 , 104, 105 ], 'ename' : ['Arun', a) Assertion is True & Reason is correct
'Geet', 'Amy'] } explanation of Assertion
df1 = pp.DataFrame(D) b) Assertion is True, but Reason is partially
print(df1) True
a) import pandas c) Assertion is True but Reason is False
b) import pandas as pp d) Both Assertion and Reason are False
c) import Pandas as pp
d) import pandas as pd Q10) Assertion – Two basic data structure in
Python are: Series and Dataframe. But both
Q3) A dataframe in Python Pandas can be are different from each other.
created using – Reason - Series stores heterogenous data while
a) A Python dictionary Dataframe stores homogenous data.
b) A scalar value a) Assertion is True & Reason is correct
c) A List explanation of Assertion
d) All of these b) Assertion is True, but Reason is partially
True
Q4) The axis = 0 is used to identify a c) Assertion is True but Reason is False
dataframe’s d) Both Assertion and Reason are False
a) rows b) columns e)
c) datatype d) values Answer Key:-

Q5) The axis = 1 is used to identify a 1 2 3 4 5 6 7 8 9 10


dataframe’s
c B d A b c d c a c
a) values b) columns
c) datatype d) rows
Q6) Missing data in a Dataframe object is
represented through –
a) NULL b) None
c) NaN d) <empty>

Q7) The function to create a dataframe from a


CSV file is –
a) to_csv() b)load_csv()
c) fetch_csv d) read_csv()

Q8) From a 4(rows) x 3(columns) size


dataframe, we can extract total different series
based on index and columns will be
a) 4 b) 3
c) 7 d) 12

9 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2


Dataframe display & Iteration 1 102 91
Write correct Python statement to 2 103 92
display 2nd,3rd,4th rows and 6th,7th c)
columns from a DataFrame Sales. Rollno Name Marks
a) Sales.loc[2:4,6:7] 2 103 Divya 92
b) Sales.loc[6:7,2:4] d)
c) Sales.iloc[2:4,6:7] Rollno Marks
e) 2 103 92
d)Sales.iloc[6:7,2:4]
Write correct Python statement to display 2nd
column of DataFrame DF. Write output of the following Python code:
a) DF[2] b) DF[[2]] Import pandas as pd
c) DF.loc[:,2] d)All of the above df=pd.DataFrame([10,20,30])
Explain the meaning of print(df.iloc[:4]) print(df)
where df is a dataframe. a)
a) It will display first 4 rows of 0 1 2
DataFrame df. 0 10 20 30
b) It will display 4th row of DataFrame b)
df. 0
c) It will display last 4 rows of 0 10
DataFarme df 1 20
d) None of these
2 30
Which is the correct Python statement to
display last 6 rows of DataFrame Item of c)
10 rows with some columns? 0
a) Item.loc[4:9] 1 10
b) Item.loc[9:4] 2 20
c) Item.loc[:10] 3 30
d) Item.loc[:11] d)
Given a DataFrame DF:
1 2 3
Rollno Name Marks
0 101 Mayank 89
0 10 20 30
1 102 Harish 91 Given a DataFrame Products which shows
2 103 Divya 92 year wise of Products :
Write a Python statement to display only 2018 2019 2020
name of student of first and second rows. TV 101 105 108
a) DF.loc[0:2,‘Name’) AC 56 59 62
b) DF.loc[0:1,0:1]) Computer 69 58 74
c) DF.loc[0:2,1] Laptop 120 125 135
d) DF.loc[1:2,’Name’] Write Python statement to display first two
Write Python statement to display Rollno and columns of the above DataFrame.
Marks column of above DataFrame DF. a) Products[[2018,2019]]
a) DF.loc[:] b) Products.loc[:,2018:2019]
b) DF.loc[1:2,’Rollno’:Marks’] c) Only a
c) DF.loc[:,[‘Rollno’,’Marks’]] d) Both a and b
d) DF.loc[[‘Rollno’,’Marks’,:] Q.20 Write Python statement to display last two
Write output of the following Python . rows of the above DataFrame Products.
statement for the DataFrame DF given in a) Products.loc[2:]
Q.15. b) Products.loc[‘Computer’:’Laptop’]
print(DF.loc[:1,’Rollno’:’Marks’]) c) Products.loc[2:3]
a) d) Products.loc[:’Laptop’]
Rollno Name Marks Answer Key:-
0 101 Mayank 89 11 a 12 d 13 a 14 a 15 d
1 102 Harish 91
16 c 17 a 18 b 19 a 20 b
b)
Rollno Marks
0 101 89

10 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2


Operation on rows and columns Answer Key:-
Q21 Inplace=True means:- 21 22 23 24 25 26 27 28 29 30
(a) Changes will be permanent a a d c a a c d a b
(b) Changes are temporary
(c) Changes are partial and temporary Head and Tail and Rename
(d) None of all Choose the correct function to
Q22. Df1.sum() will find rename citycolumns to location using
(a) total of all values of each column rename() function:
(b) total of all values of each rows a. df.rename(columns={‘City’:’Location’})
(c) count total rows b. df.rename(columns={‘City’=’Location’})
(d) count total columns c. df.rename(‘City’=’Location’)
Q23.To change the 5th column's value at 3rd row d. df.rename(df.columns(‘City’,’Location’))
as 35 in dataframe DF, you can write .
(a) DF[4, 6] = 35 (b) DF[3, 5] = 35 Which of the following statement(s)
(c) DF.at[4, 6] = 35 (d) DF.at[3, 5] = 35 is/are correct with respect to
Q24. To delete a column from a DataFrame, you df.columns properties to rename
may use statement. columns
(a) drop (b) del 1. All columns must be specified
(c) both a and b (d) None of all 2. Columns must be in the form of a list
3. Old column names not required
Q25. To delete a row from a DataFrame, you may 4. Columns can be specified with columns number
use statement. a. Only 1 is correct
(a) drop (b) del b. 1, 2 and 3 are correct
(c) both a and b (d) None of all c .1 and 3 are correct
d. All of them are correct
Q26. Which command will be used to delete 3rd and
5th rows of the data frame. Assuming the data df.index property can be used to a
frame name as DF. rename rows
(a) DF.drop([2,4],axis=0) b rename columns
(b)DF.drop([2,4],axis=1) c rename rows and columns both
(c) DF.drop([3,5],axis=1) d None of all
(d)DF.drop([3,5]) To display 2 rows from the top in the
dataframe, which of the following
Q27. To display 3rd ,4th and 5th column from the 6th
statement is correct:
to 9th rows of a dataframe DF , you can write-------- a df.head()=2 b. df.head(2)
--------. ?
c. df.head(range(2)) d. All of the above
(a) DF.loc[6:9,3:5] (b) DF.loc[6:10,3:6]
Which of the following function
(c)DF.iloc[5:9,2:5] (d)DF.iloc[6:9,3:5] display the last 5 rows from the
Q28. To change the 3rd column's value at 4th row DataFrame?
as 10 in dataframe DF, you can write . a. head( ) b. tail( )
(a) DF[3, 4] = 10 (b) DF[3, 5] = 10 c. Tail( ) d. None of the above
(c) DF.at[3, 5] = 10 (d) DF.at[3, 4] = 10 Q. 36. Replace the row label ‘Ankit’ with ‘Ankita’ in
Q29. Method or function to add a new row in a data dataframe ‘DF’
frame is: a. DF.Rename({‘Ankit’ : ‘Ankita’})
(a) .loc() (b).iloc() (c). join (d). add() b. DF.rename({‘Ankit’ : ‘Ankita’})
Q30. Which command will be used to delete 3rd c. DF.repalce({‘Ankit’:’Ankita’})
and 5th columnof the data frame. Assuming the d. None of the above
data frame name as DF. Replace the column label from 2016 to
(a) DF.drop([2,4],axis=0) 2020.
(b) (b)DF.drop([2,4],axis=1) a. DF.rename({2016 : 2020}, axis = ‘columns’)
(c)DF.drop([3,5],axis=1) b. DF.rename({2016 : 2020}, axis = ‘index’)
(d)DF.drop([3,5]) c. DF.rename({2016 : 2020}, axis = ‘column’)
d. DF.rename({2016 : 2020}, axis = columns)
11 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2
DF1.head() statement will display
rows from DataFrame ‘DF1’.
a. All b. 2 c. 3 d. 5

12 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2


Display first row of dataframe ‘DF’ statements
a. print(DF.head(1))
b. print(DF[0 : 1])
c. print(DF.iloc[0 : 1])
d. All of the above
To print first two columns of the data framedf
we shall use:-
a. df.head(2) b. df.tail(2)
c. df.iloc[0:,0:2] d. df.head()
Answer Key:-
31 32 33 34 35 36 37 38 39 40
a b a B b b a d d c

TOPIC :- INDEXING AND BOOLEAN INDEXING


Q41. Choose the correct answer if the command
df.loc[‘xyz’:’pqr’] command is executed in given
dataframe df.
aaa bbb ccc
xyz 1 2 3
mno 4 5 6
pqr 7 8 9
a. All three rows will be selected and printed
b. Only first and last rows will be selected and
printed
c. First two rows will be selected and printed
d. None of all
To make the column ‘aaa’ as new
index of
dataframe df, Correct command is
a. df.new_index('aaa', inplace=True)
b. df.setIndex(‘aaa’, inplace=True)
c. df.set_index(‘aaa’, inplace=True)
d. df.reset_index(‘aaa’, inplace=True)

Identify incorrect command to print column


‘aaa’ of above given df
a. print(df.aaa)
b. print(df.’aaa’)
c. print(df[‘aaa’])
d. print(df.loc[‘xyz’: ,’aaa’])
Choose correct option to print column ‘aaa’
a. print(df[‘aaa’])
b. print(df.loc[ ‘xyz’: , ’aaa’ ])
c. print(df.aaa)
d. All are correct
To print first two columns of dataframe df is
a. df.head(2)
b. df.tail(2)
c. df.head()
d. None of all
Q 46. Choose the correct option bases on the two
13 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2
Statement 1 :-Labeled indexing uses rows and c.
columns title to select data in the DataFrame
Statement 2 :- In boolean indexing, we will select
rows or columns based on the actual values of the
data in the DataFrame
a. Statement 1 is valid but statement 2 is
invalid
b. Statement 1 is invalid but statement 2
isvalid
c. Both statement are valid
d. Both statements are invalid
Consider the dataframe df1 given
below andanswer the following
questions
Hindi English IP
Aditya 34 23 67
Aman 34 85 56
Rajesh 60 80 91
Mohit 45 21 32
Choose correct output for the
commanddf1[[True,False,False,True]]
a.
Hindi English IP
Aditya 34 23 67
Aman 34 85 56

b.
Hindi English IP
Aditya 34 23 67
Rajesh 60 80 91

c.
Hindi English IP
Aditya 34 23 67
Mohit 45 21 32

d.
Hindi English IP
Aman 34 85 56
Rajesh 60 80 91
Output of the command print(df1[‘IP’]==91)
a.
Aditya False
Aman False
Rajesh True
Mohit False

b. Aditya False
Aman False
Rajesh True
Mohit False
Name : IP, dtype:
int64
14 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2
Aditya False d. none of the above
Aman False
Rajesh True 3. The command to install the matplotlib is:
Mohit False a. install pip matplotlib
Name : IP, dtype: bool b. install matplotlib
d. c. pip matplotlib
Rajesh True d. pip install matplotlib
Name : IP, dtype: bool

To select rows where 50 and above marks are 4. Which graph should be used where each
stored in English subject is column represents a range of values, and
Hindi English IP the height of a column corresponds to how
Aman 34 85 56 many values are in that range?
Rajesh 60 80 91 a. plot
b. line
a. df[df[‘English’]>50] c. bar
b. df[df[‘English’]>=50] d. histogram
c. df[df[‘English’]=>50]
d. df[df[‘English’]==50] 5. Data visualisation means
a. Analysis of data
To print marks of English which is 50 and b. Recovery of data
above, the correct command is c. Graphical representation of data
Aman 85 d. None of the above
Rajesh 80
Name : English, dtype: int64 6. Module used for plotting using matplotlib is:
a. plot
a. df[df[‘English’]>=50][‘English’]
b. df[‘English’][df[‘English’]>=50] b. pyplot
c. Both a and b are correct c. draw
d. None of all d. all the above
Answer Key:-
41 42 43 44 45 46 47 48 49 50 7. Which of the following is not a component
a c b d d c c c b c of plot?
a. legend
b. x axis
Data Visualization: - c. title
1. The command used to give a heading to a d. index
graph is .
a. plt.show() 8. Function of pyplot module used to create
figure is:
b. plt.plot() a. draw()
c. plt.xlabel() b. plot()
d. plt.title() c. show()
2. Using Python Matplotlib can be d. All the above
used to count how many values fall into each 9. Function of pyplot module used to display
interval. the figure created using plot() function is/
are:
a. line plot
a. draw()
b. bar graph b. plot()
c. show()
c. histogram
d. All the above

15 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2


10. Function of pyplot module used to save the 17. Which of the following is valid code for
figure is: adding title to plot?
a. save() a. plt.Title(‘kvsrojaipur’)
b. savefigure() b. plt.head(‘kvsrojaipur’)
c. savefig() c. plt.title(‘kvsrojaipur’)
d. all the above d. all the above

11. Which of the following is a valid kind 18. Valid code to import pyplot module of
argument of plot() function matplotlib is
a. line a. import matplotlib as plt
b. hist b. import pyplot as plt
c. bar c. import matplotlib.pyplot as plt
d. color d. none of the above
19. Argument used to set the line style of line
12. Function used to set x label of the plot chart is:
a. label() a. linetype
b. xticks() b. linestyle
c. xlabel() c. line
d. none of the above d. all the above

13. Which argument is used to change the 20. Which of the following is not a valid chart
colour of plotted data? type in Python?
a. datacolor a. lineplot
b. color b. bargraph
c. plotcolour c. histogram
d. none of the above d. statistical

21. Which Python package is used for 2D


14. Which argument is used to change the graphics?
width of line in line graph? (a) matplotlib.pyplot
a. markersize (b) matplotlib.pip
b. linestyle (c) matplotlib.numpy
c. linewidth (d) matplotlib.plt
d. width 22. The most popular data visualization library in
Python is:
15. Which of the following is valid code for (a) pip
adding title to plot? (b) matinfolib
a. plt.Title(‘ip cs by yogendra sir’) (c) matplotlib
b. plt.head(‘ip cs by yogendra sir’) (d) matpiplib
c. plt.title(‘ip cs by yogendra sir’) 23. Matplotlib allows you to create:
d. all the above (a) table
(b) charts
16. Starting from which version ,Pandas (c) maps
objects Series and DataFrame come (d) infographics
equipped with their own .plot() 24. Which of the following is not a visualization
methods. under matplotlib?
a. version 0.17.1 (a) Scatter plot
b. version 0.17.0 (b) Histogram
c. version 0.17.2 (c) Box plot
d. none of the above (d) Table plot

16 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2


25. Which plot displays the distribution of data
based on the five-number summary?
(a) Scatter plot
(b) Line plot
(c) Box plot
(d) Chart plot
31 For 2D plotting using a Python library, which
26. Which of the following commands is used to library interface is often used ,
install matplotlib for coding?
(a) import plt.matplotlib as plot a) Seaborn
(b) import plot.matplotlib as pt b) plotly
(c) import matplotlib.plt as plot c) matplotlib
(d) import matplotlib.pyplot as plt d) matplotlib.pyplot
32. Which of the followings are not a valid chart
27. Which of the following methods should be type ?
employed in the code to display a plot()?
(a) show() a) Statistical
(b) display() b) Boxe
(c) execute() c) Pie
(d) plot() d) plot( )
33. Which of the following is not a valid plotting
28. Which of the following statements is used to function of pyplot ?
create a histogram of 'step' type with 20 bins? a) pie( )
(a) plt.hist(x, bins = 20, histype = "barstacked") b) plot( )
(b) plt.hist(x, bins = 20) c) bar( )
(c) plt.hist(x, bins = 20, histype = "step") d) line( )
(d) plt.hist(x, bins = 20, histype = hist())
34. Point out the correct combination with
29. which one of these is not a valid line style in
regards to kind keyword for graph plotting.
matplotlib
(a) ‘-’ (a) ‘hist’ for histogram
(b) ‘--’ (b) ‘box’ for boxplot
(c) ‘-.’ (c) ‘area’ for area plots
(d) ‘<’ (d) all of the above
30. The part of chart which identifies different
sets of data plotted on plot by using different 35. The plot which tells the trend between two
colours is called: graphed variables is the
(a) legends
(b) title (a) scatter graph/chart.
(c) axes (b) pie
(d) figure (c) bar
(d) line
Answers Key: 36. Which of the following functions is used to
create a line chart ?
1 2 3 4 5 6 7 8 9 10
d c d d c b d b c c (a) line( )
11 12 13 14 15 16 17 18 19 20 (b) plot( )
(c) chart()
d c b c c b c c b d
(d) plotline( )
21 22 23 24 25 26 27 28 29 30 37. Which of the following function will produce a
vertical bar chart ?
(a) plotbar( )

17 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2


(b) plot( ) 45. Which function would you use to set the limits
(c) bar( ) for x-axis of the plot?
(d) barh( )
38. Which of the following function will create a (a) limits( )
vertical bar chart ? (b) xlimits( )
(c) xlim()
(a) plot( ) (d) lim( )
(b) bar( )
(c) plotbar() 46. Which function is used to show legends?
(d) barh( ) (a) display( )
39. Which of the following function will create a (b) show( )
horizontal bar chart ? (c) legend( )
(d) legends( )
(a) plot( )
(b) bar( ) 47. Which argument must be set with plotting
(c) plotbar( ) functions for legend( ) to display the legends ?
(d) barh( )
(a) data
40. The data points plotted on a graph are called (b) label
(a) points (c) name
(b) pointers (d) sequence
(c) marks graph is a type of chart which
displays information as a series of data 48. Which function is used to create a histogram ?
points (a) histogram( )
(d) markers (b) histo( )
41. A graph connected by straight line segments. (c) hist()
(a) line (d) histtype
(b) bar
(c) pie 49. Which of the following is not a valid plotting
(d) boxplot function of pyplot ?
42. Which argument of bar() lets you set the
thickness of bar ? (a) plot( )
(b) bar( )
(a) thick (c) line()
(b) thickness (d) pie( )
(c) width
(d) barwidth 50. In which of the installation matplotlib is
43. Which function lets you set the title of the already present?
plot? (a) Standard official Distribution
(a) title( ) (b) Installed python using Anaconda
(b) graphtitle(). (c) Installed Python using King Cobra
(c) plottitle( ) (d) Installed python using C++
(d) All of these
44. The command used to give a heading to a Answers Key:
graph is 31 32 33 34 35 36 37 38 39 40
d a d d d b c b d d
(a) plt.show() 41 42 43 44 45 46 47 48 49 50
(b) plt.plot() a c a d c c b c c b
(c) plt.xlabel( )
(d) plt.title( )

18 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2


Digital Footprint, Net etiquette, Data the order of a sentence and changing some
Protection, IPR, FOSS, Plagiarism, license, of the work.
copyrights d) All the above
Q1. A is a body of data that you Q9. It is a form of protection given to the
create while using the Internet: authors of “original works of authorship”.
a) Digital Sign print a) License
b) Digital hand print b) Copyright
c) Digital footprint c) Non-License
d) Digital head print d) User rights
Q2. FOSS stands for: Q10. Permissive licenses provide a royalty-free
a) Free opening System software license to do virtually anything with the
b) Free opened Source Software source code. Do you….?
c) Free opens System Software a) Agree
d) Free and Open Source Software b) Disagree
Q3. What is the Full form of IPR: c) Can’t say
a) Intelligent Product Rights d) None of above
b) Intellectual Property Reserves Q11. Exclusive rights in the software are
c) Intellectual Property Rights retained with the owner /developer
d) Intelligent Property Rights / publisher are known as……………:
a) Open Source Software
Q4. A……. digital footprint is created when data
b) Proprietary Software
is collected without the owner knowing.
c) Free Software
a) Passive
d) Freeware
b) Active
c) Objective Q12. Intellectual property always refers to
d) Subjective intangible property that has been created
Q5. A code of good behavior on the Internet, is by individuals and corporations for their
Known as: benefit or usage such as copyright,
a) Etiquette trademark, patent and digital data……:
b) Native a) True
c) Netiquette b) False
d) Protocol c) Sometimes
d) Never
Q6........................refers to the practices, safeguards,
and binding rules put in place to protect Q13. A copyright is automatically granted to
your personal information and ensure authors or creators of content:
that you remain in control of it.: a) True
a) Data Security b) False
b) Data Protection c) Never
c) Data Stealing d) Can’t say
d) Unknown Data
Q14. In FOSS source code is usually hidden from
Q7. Presenting an entire text by someone else the users.
as your own work is known as ….: a) True
a) Plain Plagiarism b) False
b) Global Plagiarism c) Never
c) Local Plagiarism d) Sometimes
d) Unknown Plagiarism Q15. Anushka is using her internet connection
Q8. Plagiarism should be avoided by the to book a train ticket. This is a classic
following simple measures:: example of leaving a trail of web activities
a) Use your own ideas and words. carried by her. What do we call this type of
b) Always provide a reference or give credit to activity?
the source from where you have received a) Digital login
information. b) Digital Footprint
c) Cite the name of the website, a URL or the c) Digital Log off
name of authors, and acknowledge them if d) Digital Error
you have used their work after rearranging
19 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2
Q16. Anil likes to do his homework late at night. Q 23. Which of the following is not a violation of
He uses the Internet a lot and also sends useful data IPR?
through email to many of his friends. One Day he forgot a) Copyright Infringement
to sign out from his email account. In the morning, his b) Trademark Infringement
twin brother, Sunil started using the computer. He used c) Patent
Anil’s email account to send inappropriate messages to d) Plagiarism
his contacts. What do we call this type of activity? Q 24. Which of the following is not an OSS?
a) Stealing of Data a) LibreOffice
b) Identity Theft b) MYSQL
c) Digital Theft c) MSOffice
d) Misuse of Email d) Linux
Q17. Linux, Apache, MySQL and PHP software Q 25. The user must agree to the ……terms and
come under category. agreements when they use an OSS.
a) Proprietary Software a) System
b) FLOSS b) License
c) Freeware c) Community
d) Shareware d) Program
Q18. We should follow the rules for good Q 26. Intellectual Property Rights (IPR) protect
Etiquettes while being online. Choose the the use of information and ideas that are
right net etiquette (s) from the following: of….
a) Avoid posting offensive comments a) Social value
b) Respect others' privacy b) Moral Value
c) Don't troll people in web forums c) Commercial Value
d) All the above d) Ethical value
Q19. Ravi is a student of class -10 and he is a Q 27. Intellectual Property Rights (IPR) in India
very frequent user of internet applications Covers ……….
One day he got an unpleasant message on a) Patents
his WhatsApp. What do you think he b) Copyrights
should do? c) Trademarks
a) Forward it to others d) All the above
b) Reply back to the sender Q 28. When was Copyright Act enacted in India?
c) Switch off the device a) 1955
d) Tell to his parents about the incident b) 1957
Q20. Sunita is confused about the free operating c) 1959
system available in the market. Few of her d) 1960
friends suggested a few operating systems. Q 29. Copyright is a… .......... ?
Help her in choosing free operating system a) Negative Right
for her device:
b) Positive Right
a) Apache
b) Windows
c) Exclusive Right
c) Mozilla d) Both B and C
d) Ubuntu Q 30. Which of the following is not a fair use of a
copyrighted work?
Q 21. Aman deleted all his chats from all his
a) Use for research
social media accounts, and he thinks that
all his traces are deleted completely. Is he
b) Use for criticism
right in thinking so? c) Use for review
a) No d) Use for commercial purpose
b) Yes Answers:
c) May be 1 2 3 4 5 6 7 8 9 10
d) Not Sure c d c a c b b d b a
Q 22. is the practice of taking 11 12 13 14 15 16 17 18 19 20
someone else's work or ideas and passing b a a b b b b d d d
them off as one's own: 21 22 23 24 25 26 27 28 29 30
a) Plagiarism
a a c c b c d b d d
b) Copyright
c) Patent
d) All of the above
20 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2
Cybercrime and cyber laws, Q9. Hackers try to break security system _
hacking, phishing, cyber bullying, a) for Identity theft
b) for monetary gain
overview of Indian IT Act.
c) to leak sensitive information
Q1. is defined as a crime in which the
d) All of the above
computer is the medium of crime.
Q10. is an activity where fake
a) Computer crime
websites or emails that look original or authentic
b) Cyber crime
are presented to the user.
c) Internet crime
a) Phishing
d) Digital crime
b) Hacking
Q2. Which of the following is cybercrime?
c) Spamming
a) Hacking
d) Identity theft
b) Phishing
Q11. What is the most important activity in system
c) Spamming
hacking?
d) All of the above
a) Information gathering
Q3. A is some lines of malicious code that
b) Cracking passwords
can copy itself and can have detrimental effect on
c) Escalating privileges
the computers, by destroying data or corrupting
d) Covering tracks
the system.
Q12. Online posting of rumours, giving threats
a) Cyber crime
online, posting the victim’s personal information,
b) Computer virus
comments aimed to publicly ridicule a victim is
c) Program
termed as
d) Software
a) Cyber bullying
Q4. is the act of unauthorized access to
b) Cyber crime
a computer, computer network or any digital
c) Cyber insult
system.
d) All of the above
a) Sign in
Q13. In India law provides guidelines to the
b) Hacking
user on the processing, storage and transmission
c) Tracking
of sensitive information.
d) None of the above
a) Information Technology Act, 2000
Q5. Hacking, when done with a positive intent, is b) Indian Technology Act, 2000
called c) Inform Technology Act, 2000
a) Ethical hacking d) Information Techware Act, 2000
b) Active hacking Q14. Which of the following are feasible methods
c) Passive hacking of e-waste management?
d) Ethics a) Reduce
Q6. Which of the following is called black hat b) Reuse
hacker? c) Recycle
a) Ethical hacker d) All of the above
b) Non-Ethical hacker Q15. The process of re-selling old electronic goods
c) Both of the above at lower prices is called
d) None of the above a) refurbishing
Q7. Primary focus of is on security cracking b) recycle
and data stealing. c) reuse
a) ethical hacker d) Reduce
b) non ethical hacker Q16. e-waste is responsible for air, water and land
c) white hat hacker pollution. (T/F)
d) None of the above a) True
Q8. Which of the following is not a cyber-crime? b) False
a) Phishing Q17 e-waste is responsible for the degradation of
b) Ransomware our environment. (T/F)
c) Hacking a) True
d) Tracking b) False
21 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2
Q18. Bad posture of using computer may cause

a) Backache
b) Neck Pain
c) Shoulder pain
d) All of the above
Q19. What we have to ensures to maintain good
health of a computer system?
a) Wipe monitor’s screen often using the regular
microfiber soft cloth.
b) Keep it away from direct heat, sunlight and put
it in a room with enough ventilation for air
circulation.
c) Do not eat food or drink over the keyboard
d) All of the above
Q20. is a person who deliberately sows
discord on the Internet by starting quarrels or
upsetting people, by posting inflammatory or off
topic messages in an online community.
a) Netizen
b) Digital Citizen
c) Internet troll
d) None of the above
Q21.Which is bout internet effects on eye
a) Blurred vision
b) Dry Eyes
c) Tears
d) All of the above
Q22 Which of the following is not a type of cyber-
crime?
a) Data theft
b) Forgery
c) Damage to data and systems
d) Installing antivirus for protection
Q23. In which of the following, a person is
constantly followed/chased by another person or
group of several peoples?
a) Phishing
b) Bulling
c) Stalking
d) Identity theft
Q24. is an application of information and
communication technology (ICT) for delivering
Government Service.
a) Governance
b) Electronic Governance
c) Governance and Ethics
d) Risk and Governance.
Q25. Use of electronic messaging systems to send
unsolicited bulk messages are called
a) email bombing
b) Spamming

22 Informatics Practices (065) S e s s i o n 2 0 2 1 - 2 2

You might also like