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

Atmiya Vidyapeeth

Gandhidham Shinay

SERIES CLASS TEST


Class 12 - Informatics Practices
Time Allowed: 1 minute Maximum Marks: 112

1. NaN stands for: [1]

a) None a Number b) Not a Number

c) None and None d) Null and Null


2. Which of the following is not Pandas data structure? [1]

a) Queue b) Series

c) Data Frame d) None of these


3. Name the data structure that used in Pandas. [2]
4. What is data structure? [2]
5. What do you mean by Series in Python? [2]
6. Differentiate between Series and DataFrame. [3]
7. Assertion (A): Dictionaries cannot be used to create a Series object. [1]
Reason (R): Dictionaries have key,value pairs and Series is a one dimensional data structure.

a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.


8. All pandas data structures are ________ mutable but not always ________ mutable. [1]

a) semantic,size b) value, size

c) size, value d) none of these


9. To create an empty Series object, you can use: [1]

a) pd.Series b) pd.Series(NaN)

c) pd.Series(empty) d) all of these


10. You can create a Python pandas series using? [1]

a) all of these b) tuple

c) sequence d) ndarray
11. Consider the following Series in Python [1]
data = pd.Series([5, 2, 3, 7], index=['a', 'b', 'c', 'd'])
Which statement will display all odd values?

a) print(data(data%2!=0)) b) print(data[data%2!=0])

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

1/9
Atmiya Vidyapeeth
12. When an operation is carried out on every value of Series object is called ________. [1]

a) None of these b) Scalar Operation

c) Both Scalar Operation and Vector Operation d) Vector Operation


13. To display last five rows of a Series object S, You may write: [1]

a) head() b) tell()

c) tail(3) d) tail()
14. To display the second element of Series we can use: [1]

a) s[:1] b) s[:2]

c) s[1] d) s[2]
15. To display third element of a Series object S, you will write ________. [1]

a) S[3] b) S[2]

c) S[:3] d) S[:2]
16. What will be the output of the following code? [1]

import pandas as pd
import numpy
s=pd.Series(data=[31, 54, 34, 89, 12, 23],dtype=numpy.int)
print(s>50)

a) 1 54 b) 0 31
3 89 1 54
dtype: int64 2 34
3 89
4 12
5 23
dtype: bool

c) 1 True d) 0 False
3 True 1 True
dtype: bool 2 False
3 True
4 False
5 False
dtype: bool
17. Find the output of given code: [1]

import pandas as pd
s=pd.Series(['a','s','r'], index=[2,6,9])
print(s>='s')

a) 2 False b) 2 False

2/9
Atmiya Vidyapeeth
6 False 6 True
9 False 9 False

c) 2 True d) 2 False
6 False 6 False
9 True 9 True
18. Write the output of the given code. [1]

import pandas as pd
S1=pd.Series([5, 6, 7, 8, 10], index=['v', 'w', 'x', 'y', 'z'])
l=[2, 6, 1, 4, 6]
S2=pd.Series(l,index=['z', 'y', 'a', 'w', 'v'])
print(S1-S2)

a) a NaN b) v -1.0
v -1.0 w 2.0
w 2.0 y 2.0
x 3.0 z 8.0
y 2.0 dtype: float64
z 8.0
dtype: float64

c) a NaN d) a 0
v -1.0 v -1.0
w 2.0 w 2.0
x NaN x NaN
y 2.0 y 2.0
z 8.0 z 8.0
dtype: float64 dtype: float64
19. Write the output of the following: [1]

import numpy as num


import pandas as pd
arr=num.array([1,7,21])
S1 = pd.Series(arr)
print(S1)

20. Give the output: [2]

import pandas as pd
name=['Raj', 'Ankur', 'Harsh']
p=pd.Series(name, index=[2,5,6])
print(p)
# Reindex the series and create a new series variable
p1=p.reindex([6,2,5])
print (p1)

3/9
Atmiya Vidyapeeth
21. Write a program to print the values of 0, 2, 4 positions from Series s[10,20,30,40,50] using .iloc. [2]
22. Write a program to create an empty series [2]
#import the pandas library and aliasing as pd
23. What do you mean by Series data structure? [2]
24. What is series? Explain with the help of an example. [2]
25. Write a program to create a series from a given Tuple data data=('1', 'Aman', 86.3, 'A'). [2]
26. Write the syntax to sort the series values using indexes in descending order. [2]
27. Give the output: [2]

import pandas as pd
S = pd.Series([10,20,30,40,50], index = ['a', 'e', 'i', 'o', 'u'])
print(S)
# Assigning New Index Values
S.index = [1, 2, 3, 4, 5]
print("Series after new index values")
print(S)

28. Give the output: [2]


import pandas as pd
s=pd.Series([10,20,30,40,50], index = ['a', 'b', 'c', 0, 1])
print(s.loc['a'])
print(s.loc[0])
29. Write single line Pandas statement to declare a Pandas series named Packets having dataset as: [125, 92, 104, 92, [2]
85, 116, 87, 90]
30. Write a program to create a series from ndarray with elements 'a’, ’b', 'c', 'd'. [2]
31. Complete the code to get the required output : [2]
import ________ as pd
________ = pd.Series([31, 28, 31], index = ["Jan", "Feb", "Mar"] )
print(S1["________"])
OUTPUT:
28
32. Consider the series object srl that stores the salary of teacher, as shown below. Here Teacher’s name represents [3]
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.
33. Write the code to produce following Series and also display this Series in descending order of its index. [3]

d 225

b 720

a 840

4/9
Atmiya Vidyapeeth
c 650

e 950

34. How to create a Series from lists? [3]


35. Show the first 3 values from Series using iloc. [3]
36. Give the output of the following statements based on given code. [3]

import pandas as pd
import numpy as np
data=np.array(['E', 'N', 'V', 'I', 'R', 'O', 'N', 'M', 'E', 'N', 'T'])
a=pd.Series(data)

i. a[: -5]
ii. a [3 : 7]
37. Give the output: [3]
import pandas as pd
s=pd.Series([10,20,30,40,50], index =['a', 'b', 'c', 0, 1])
print(s.loc['a':'c'])
38. Write the output of the following code, considering the Series sr as given below [3]
0 Computer
1 Maths
2 Science
3 English
4 Hindi
5 Social Science
i. print (sr[3 : 5])
ii. print (sr. index)
iii. print (sr. values)
iv. print (sr[0 : 2])
39. Write the output of the following code. [3]

import pandas as pd
import numpy as np
tin=[1, 2, 3, 4, 5]
data1=['a', 'b', 'c', 'd', 'e']
a=pd.Series(data = tin, index=data1, dtype = np.float64)
print(a)

40. How can you create an empty series? [3]


41. Differentiate between Pandas Series and NumPy Arrays. [3]
42. Assertion (A): pop() methodreturns the series as aresult. [1]
Reason (R): pop() method is used to delete the series.

a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.

5/9
Atmiya Vidyapeeth
c) A is true but R is false. d) A is false but R is true.
43. Assertion (A): empty property: This property returns True if the Series is empty otherwise return False. [1]
Reason (R): empty property of Series does not help to check whether a Series is empty or not?

a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.


44. Assertion (A): We cannot access more than one element of Series without slicing. [1]
Reason (R): More than one element of series can be accessed using a list of positional index or labeled index.

a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.


45. Assertion (A): We can perform mathematical operations on two series objects of different size but not on two 1 [1]
D arrays of different size.
Reason (R): if two series are not aligned NaN are generated but in case of arrays no concept of NaN and hence
operations fail to perform.

a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.


46. Assertion (A): A Series is a one-dimensional array containing a sequence of values of any data type (int, float, [1]
list, string, etc).
Reason (R): Pandas Series can be imagined as a column in a spreadsheet.

a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.


47. Assertion (A): To display the first four elements of a Series object, you may write S[:4]. [1]
Reason(R): To display the first five rows of a Series object S, you may use tail() function.

a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.


48. Assertion (A): We can add two series objects using addition operator(+) or calling explicit function add(). [1]
Reason (R): While adding two series objects index matching is implemented and missing values are filled with
NaN by default.

a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.


49. Assertion (A): size attribute of Series objects returns length of series. [1]
Reason (R): count() will ignore the nan values in returning the output.

a) Both A and R are true and R is the correct b) Both A and R are true but R is not the

6/9
Atmiya Vidyapeeth
explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.


50. Assertion (A): Elements of Series can be accessed using positional index. [1]
Reason (R): positional index values ranges from 1 to n if n is the size of the series.

a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.


51. Assertion (A): Series() function is used to create empty series. [1]
Reason (R): Series() function is used to create Series.

a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.


52. To check if the Series object contains NaN values, ________ attribute is displayed. [1]

a) nbytes b) hasnans

c) ndim d) dtype
53. To get the number of elements of a Series object. ________ attribute may be used. [1]

a) itemsize b) size

c) index d) ndim
54. To get the number of dimensions of a Series object. ________ attribute is displayed. [1]

a) index b) itemsize

c) size d) ndim
55. To display a series 'S' in descending order select the correct statement; [1]
i. S.sort_values(asc=False)
ii. S.sort(asc=False)
iii. S.sort_values(ascending=False)
iv. S.sort(ascending=False)

a) Option (iii) b) Option (i)

c) Option (iv) d) Option (ii)


56. Which of the following statement is wrong [1]
a. Cannot 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 empty Series.

a) Option (c) b) Option (b)

c) Option (d) d) Option (a)


57. State True or False: [3]
(i) To short the series values using values, use sort_values() function. [1]

7/9
Atmiya Vidyapeeth
(ii) List and tuple can be easily converted into Series by Series() method. [1]
(iii) The data value of series object can be modified using value assignment. [1]
58. Fill in the blanks: [6]
(i) The operation is performed only on the ________ indexes. [1]
(ii) ________ slice operation is used to print whole series. [1]
(iii) if the output is 71. [1]
import pandas as pd
S1 = pd.Series([10, 20, 30, 40, 71,50])
print(S1[ ________ ])
(iv) ________ can be done either in ascending or descending order. [1]
(v) Size of series is ________. [1]
(vi) Series is ________ dimensional array with homogeneous data. [1]
Question No. 59 to 63 are based on the given text. Read the text carefully and answer the questions: [5]
Priyanka, a student of Class XII, has been assigned a code to create a pandas Series 'ST', as shown below.

a 100

b 200

c 300

d 400

e 500

dtype: int64

With reference to the above information, answer given questions:

59. Choose the command that will give the following output.

b 200

c 300

dtype: int64

a) print(S1[2:4]) b) print(S1[1:3])

c) print(S1[:3]) d) print(S1[0:3])
60. Help him to identify the correct statement that can be used to extract the value with the index 'c'.

a) print(S1[c]) b) print(S1(c))

c) print('S1' ['c']) d) print(S1['c'])


61. Which of the following command will give the following output?

b 200

d 400

dtype: int64

a) print(S1.iloc[2:4]) b) print(S1.iloc[l:4])

8/9
Atmiya Vidyapeeth
c) print(S1.iloc[1:4:2]) d) print(S1.iloc(1:4))
62. Which of the following command will display the series by adding 10 in each value?

a) print(S1)+10 b) print(S1)+print(10)

c) print(S1 + 10) d) print(S1[+10])


63. Priyanka wants to delete the value against index 'd' Help him to choose the suitable option to do so.

a) S1=S1.drop('d') b) S1=S1.drop['d']

c) S1=drop('d') d) S1=S1.drop(d)

Question No. 64 to 68 are based on the given text. Read the text carefully and answer the questions: [5]
Priyanka, a student of Class XII, has been assigned a code to create a pandas Series 'ST', as shown below.

a 100

b 200

c 300

d 400

e 500

dtype: int64

With reference to the above information, answer given questions:

64. Choose the command that will give the following output.

b 200

c 300

dtype: int64

65. Help him to identify the correct statement that can be used to extract the value with the index 'c'.
66. Write the command that will give the following output?

b 200

d 400

dtype: int64

67. Write the command that will display the series by adding 10 in each value?
68. Priyanka wants to delete the value against index 'd' Help him to choose the suitable option to do so.

9/9
Atmiya Vidyapeeth

You might also like