This practice paper is designed in such a way that it covers all the questions like MCQs, True/False, Theory Questions, Coding Questions as well as Output Question as per the CBSE Syllabus. By practicing it students will learn different types of questions related to Series and gain more confidence to write the answers in board exams.
I have already explained series creation practice problem in my previous practice paper Python Series Practice Questions with Solutions (Part-I).
SECTION-I Multiple Choice Questions
1. To create an empty Series object, you can use: |
a) Series (empty) |
b) pandas.Series(np.NaN) |
c) Series() |
d) all of these |
Answer : option c) Series() |
2. To display first three elements of a Series Object S, you may write….. |
a) S[1:4] |
b) S[1:3] |
c) S[:3] |
d) all of these |
Answer : option c) S[:3] : it starts from index number 0 and end to 2 i.e. 0,1,2 (three elements) |
3. Which of the following is not a valid attribute for Series object |
a) index |
b) datatype |
c) itemsize |
d) hasnans |
Answer : option b) datatype is not a valid attribute, if you want to know the datatype then use “dtype”. |
4. To display 3rd element of a Series Object S, which contain 5 elements and their indexes are [‘a’,’b’,’c’,’d’,’e’], you may write |
a) S[2] |
b) S[‘b’] |
c) S[‘d’] |
d) S[3] |
Answer : option a) S[2] |
5. To get the number of elements in Series object, …………………. attribute is displayed. |
a) index |
b) size |
c) itemsize |
d) ndim |
Answer : option b) size |
SECTION-II State True/False
1. A Series and List in Python are the same. |
Answer : False. Series and List are not same in Python. |
2. A series is size immutable. |
Answer : True. A series is a size immutable but value-mutable i.e. you cannot change the size of series but change the value. |
3. A series cannot hold characters/strings |
Answer : False. A series can hold characters/strings |
4. Series object’s indexes are not necessarily from 0 to n-1 always. |
Answer : True. Series can have any custom index. |
5. When Series created from a dictionary object, then keys of the dictionary become index of the Series and the values of dictionary become the data of Series object. |
Answer: True |
SECTION-III Answers the following questions
1. What is Series? How many ways you can create a Series? |
Answer : Series is a one-dimensional labeled array data structure that is capable of holding any data type. It is a key component of the popular data analysis library, Pandas. Series is essentially a column of data in a Pandas DataFrame, which is a two-dimensional labeled data structure. One of the main benefits of Series is that it provides an easy way to label and index data, making it easier to perform operations on the data and access specific elements. This labeling and indexing also allows for quick and easy data aggregation and summarization.Creating a Series in Python :1. Using a List: You can create a Series from a Python list by passing the list to the Series constructor. The list can contain any data type, including integers, strings, and floating-point numbers. The index labels for the Series are automatically generated from 0 to the length of the list. 2. Using a Dictionary: A Series can also be created from a dictionary, where the keys of the dictionary are used as the index labels and the values of the dictionary are used as the values in the Series. 3. Using ndarray: You can create a Series from a NumPy ndarray by passing the ndarray to the Series constructor. This is a useful method if you have pre-existing arrays that you want to use in your analysis. 4. Using Scalar Value: You can also create a Series from a scalar value, which will create a Series with one element and the scalar value will be repeated as the value for all elements in the Series. |
2. Write any 3 attributes of series with example. |
Answer : The three attributes of series are :
|
SECTION-IV Write the code for the following questions :
1. Create a Series object S1 that stores the number of students in 4 sections of class 12. |
2. Create a series of 5 numbers (between 1-10), then find out the numbers that are more than 5 |
3. Create a Series object S1 having 5 values. WAP to change the values at its 2nd row and 3rd row to 8000 |
4. Create a Series object SObj with 5 values. WAP to calculate cubes of the Series Values |
5. Write a code to create two series, one hold the no of employees and second hold the salaries of employees, now find the average salary of employee. |
For practice more questions, download Study Trigger mobile app.