CLASS XII SERAIES MCQ QUESTION

 Here are some MCQ questions based on Pandas Series:



Basic Pandas Series MCQs:

  1. What is a Pandas Series in Python?

    • a) A 2D array-like structure with rows and columns
    • b) A 1D labeled array capable of holding data of any type
    • c) A collection of tables
    • d) A list of dictionaries
    • Answer: b) A 1D labeled array capable of holding data of any type
  2. Which of the following is the correct way to create a Pandas Series from a list in Python?

    python
    data = [10, 20, 30, 40]
    • a) s = pd.Series([data])
    • b) s = pd.Series(data)
    • c) s = pd.DataFrame(data)
    • d) s = pd.array(data)
    • Answer: b) s = pd.Series(data)
  3. Which of the following can be used as valid data types for a Pandas Series?

    • a) Lists
    • b) NumPy arrays
    • c) Dictionaries
    • d) All of the above
    • Answer: d) All of the above
  4. By default, what does the index of a Pandas Series start with?

    • a) 0
    • b) 1
    • c) -1
    • d) The index must be explicitly defined
    • Answer: a) 0
  5. How can you access the first element of a Pandas Series s?

    • a) s[0]
    • b) s.first()
    • c) s[1]
    • d) s.head()
    • Answer: a) s[0]
  6. How can you get the index labels of a Pandas Series?

    • a) s.values
    • b) s.index
    • c) s.labels
    • d) s.columns
    • Answer: b) s.index
  7. What method would you use to return the first 3 rows of a Pandas Series s?

    • a) s.tail(3)
    • b) s.head(3)
    • c) s.first(3)
    • d) s.top(3)
    • Answer: b) s.head(3)
  8. Which method is used to return the underlying data of a Pandas Series as a NumPy array?

    • a) s.index
    • b) s.array()
    • c) s.to_numpy()
    • d) s.index.values
    • Answer: c) s.to_numpy()
  9. What does the dtype attribute of a Pandas Series return?

    • a) The data type of the values stored in the Series
    • b) The length of the Series
    • c) The index labels
    • d) The name of the Series
    • Answer: a) The data type of the values stored in the Series
  10. What happens when you try to add two Pandas Series with different index values?

    • a) Raises an error
    • b) Automatically aligns the Series based on their indexes and adds the corresponding values
    • c) Only adds the values from the first Series
    • d) Only adds the values from the second Series
    • Answer: b) Automatically aligns the Series based on their indexes and adds the corresponding values

Advanced Pandas Series MCQs:

  1. How can you give a Pandas Series a name?

    • a) Using the rename() method
    • b) Assigning a value to the name attribute
    • c) Using the set_name() method
    • d) Using the Series() constructor with the name parameter
    • Answer: b) Assigning a value to the name attribute
  2. Which method would you use to sort a Pandas Series by its index?

    • a) s.sort()
    • b) s.sort_values()
    • c) s.order()
    • d) s.sort_index()
    • Answer: d) s.sort_index()
  3. How would you check for missing values (NaN) in a Pandas Series s?

    • a) s.check_na()
    • b) s.isnull()
    • c) s.isnan()
    • d) s.empty()
    • Answer: b) s.isnull()
  4. What will the following code return?

    python
    s = pd.Series([10, 20, None, 30]) s.notnull()
    • a) A Series of boolean values indicating if the data is not missing
    • b) The first non-null value
    • c) A list of non-null values
    • d) An error
    • Answer: a) A Series of boolean values indicating if the data is not missing
  5. Which function is used to return the descriptive statistics of a Pandas Series? (outofsyllabus)

    • a) s.describe()
    • b) s.stats()
    • c) s.details()
    • d) s.summary()
    • Answer: a) s.describe()
  6. How can you change the index of a Pandas Series?

    • a) Using the index method
    • b) Using the set_index() method
    • c) Directly assigning a new index using s.index = new_index
    • d) Using the reindex() method
    • Answer: c) Directly assigning a new index using s.index = new_index
  7. How can you check if a specific label is present in a Pandas Series?

    • a) label in s
    • b) s.label_exists(label)
    • c) s.index.has_label(label)
    • d) s.contains(label)
    • Answer: a) label in s
  8. Which of the following functions can be used to append data to a Pandas Series? (outofsyllabus)

    • a) append()
    • b) concat()
    • c) extend()
    • d) merge()
    • Answer: a) append()
  9. What will the following code return?

    python
    s = pd.Series([10, 20, 30]) s + 5
    • a) [15, 25, 35]
    • b) A new Series with 5 added to each value
    • c) A new Series with values multiplied by 5
    • d) An error
    • Answer: b) A new Series with 5 added to each value
  10. Which method is used to return the unique values in a Pandas Series?

    • a) s.unique()
    • b) s.distinct()
    • c) s.drop_duplicates()
    • d) s.values_unique()
    • Answer: a) s.unique()


  1. What will the following code do?

    python
    s = pd.Series([10, 20, 30], index=['a', 'b', 'c']) s['b']
    • a) Return 10
    • b) Return 20
    • c) Return ['a', 'b', 'c']
    • d) Raise an error
    • Answer: b) Return 20
  2. How can you filter a Pandas Series s to show values greater than 15?

    • a) s > 15
    • b) s.filter(15)
    • c) s[s > 15]
    • d) s.greater(15)
    • Answer: c) s[s > 15]
  3. What does the counts() method of a Pandas Series return?

    • a) A count of unique values in the Series
    • b) The total number of elements in the Series
    • c) The number of missing values in the Series
    • d) The sum of all the values in the Series
    • Answer: a) A count of unique values in the Series
  4. Which of the following can be used to handle missing values in a Pandas Series?

    • a) fillna()
    • b) dropna()
    • c) Both a and b
    • d) drop_duplicates()
    • Answer: c) Both a and b
  5. How can you rename the index of a Pandas Series s?

    • a) s.set_index(new_index)
    • b) s.rename_index(new_index)
    • c) s.index = new_index
    • d) s.reset_index(new_index)
    • Answer: c) s.index = new_index
  6. Which of the following methods can you use to return the sum of all elements in a Pandas Series?

    • a) s.add()
    • b) s.sum()
    • c) s.count()
    • d) s.values.sum()
    • Answer: b) s.sum()
  7. What will the following code do?

    python
    s = pd.Series([1, 2, 3, 4, 5]) s[1:4]
    • a) Return the first four values of the Series
    • b) Return the second to fourth values of the Series
    • c) Return the second, third, and fourth values (index positions 1 to 3)
    • d) Raise an error
    • Answer: c) Return the second, third, and fourth values (index positions 1 to 3)
  8. How can you check if a Pandas Series is empty?

    • a) s.empty()
    • b) s.is_empty()
    • c) s.empty
    • d) len(s) == 0
    • Answer: c) s.empty

Post a Comment

0 Comments