Python MCQ Quiz Hub

Pandas MCQ Questions Set 2

Choose a topic to test your knowledge and improve your Python skills

Write the statement to get NewDelhi as output using positional index. import pandas as pd S1 = pd.Series(['NewDelhi', 'WashingtonDC', 'London', 'Paris'], index=['India', 'USA', 'UK', 'France'])





✅ Correct Answer: 1

We can access elements in Series by using ________ index and ____________index.





✅ Correct Answer: 3

Write the output of the following : import pandas as pd S1 = pd.Series(['NewDelhi', 'WashingtonDC', 'London', 'Paris'], index=['India', 'USA', 'UK', 'France']) print(S1['India', 'UK'])





✅ Correct Answer: 3

Which of the following statement will print Series ‘S1’ in reverse order?





✅ Correct Answer: 3

How many values will be modified by last statement of given code ? import pandas as pd S1 = pd.Series(['NewDelhi', 'WashingtonDC', 'London', 'Paris'], index=['A', 'B', 'C', 'D']) S1['A' : 'C'] = 'ND'





✅ Correct Answer: 2

How many values will be modified by last statement of given code ? import pandas as pd S1 = pd.Series(['NewDelhi', 'WashingtonDC', 'London', 'Paris'], index=['A', 'B', 'C', 'D']) S1['A' : 'C'] = 'ND'





✅ Correct Answer: 1

S1.values will return all the values of Series ‘S1’ in ___





✅ Correct Answer: 3

Which of the following property/attribute return total number of values in Series ‘S1’?





✅ Correct Answer: 1

Which of the following attributes returns True if there is no value in Series?





✅ Correct Answer: 3

Which of the following attributes returns all the values of Series?





✅ Correct Answer: 3

Write the output of the following code: import pandas as pd S1=pd.Series() print(pd.Series().empty)





✅ Correct Answer: 1

Write the output of the following code : import pandas as pd S1=pd.Series([1,2,3,4]) S2=pd.Series([7,8]) S3=S1+S2 print(S3.size)





✅ Correct Answer: 4

Which of the following statement shows first five values of Series ‘S1’?





✅ Correct Answer: 3

Write the output of the following : import pandas as pd S1=pd.Series([1,2,3,4]) S2=pd.Series([7,8]) print((S1+S2).count())





✅ Correct Answer: 3

Which of the following returns number of non-NaN values of Series?





✅ Correct Answer: 1

Write the output of the following : import pandas as pd S1=pd.Series([1,2,3,4]) S2=pd.Series([7,8,9,10]) S2.index=['a','b','c','d'] print((S1+S2).count())





✅ Correct Answer: 3

We can perform _____________ on two series in Pandas.





✅ Correct Answer: 4

Which of the following method is used to add two series?





✅ Correct Answer: 3

Which of the following statement will display the difference of two Series ‘A’ and ‘B’?





✅ Correct Answer: 3

Which of the following fills the missing values in Series? a.





✅ Correct Answer: 3

Which of the following function is used for basic mathematical operations in Series?





✅ Correct Answer: 4

Which of the following statement is replacing missing values of Series A and Series B by 100 .





✅ Correct Answer: 1

Mathematical Operations on two Series object is done by matching ______





✅ Correct Answer: 1

Which of the following statement will display values more than 40 from Series ‘S1’?





✅ Correct Answer: 3

Which of the following statement will return 10 values from the bottom/end of the Series ‘S1’?





✅ Correct Answer: 2

Which of the following are valid operations on Series ‘S1’?





✅ Correct Answer: 4

When an operation is carried out on every value of Series object is called __





✅ Correct Answer: 2

Which of the following statement will modify the first three values of Series ‘S1’?





✅ Correct Answer: 4

What is the index value of 31 in given Series ‘S1’? import pandas as pd S1=pd.Series([1,2,31,4], index = ['a','b','c','d'])





✅ Correct Answer: 3

S2 is ____________ in given code ? S2 = S1[2 : 5] #S1 is a Series object





✅ Correct Answer: 3

Python libraries contain a collection of built-in __





✅ Correct Answer: 2

Which of the following library help to visualize data?





✅ Correct Answer: 3

Which of the following is a high level data manipulation tool used for analyzing data.?





✅ Correct Answer: 2

Pandas is the ____ library.





✅ Correct Answer: 3

Pandas Series is size __________ and value _____





✅ Correct Answer: 3

Pandas DataFrame is size ________ and value ____





✅ Correct Answer: 1

data’ in the following code could be _____ S1 = pd.Series(data)





✅ Correct Answer: 4

Choose the correct statement : Statement1 : A Numpy array requires homogeneous data. Statement2 : Pandas DataFrame can have heterogeneous data.





✅ Correct Answer: 3

Amit is working in an IT company. His boss asked him to prepare a chart in python. He is confused that which library will support plotting graph and data visualization in python. Help him to find the library





✅ Correct Answer: 2

By using Matplotlib, we can generate __





✅ Correct Answer: 4

Installing Pandas is very similar to installing __





✅ Correct Answer: 2

By default Series have _______ data labels starting from ___.





✅ Correct Answer: 3

Write a statement to import pandas with alias name ‘pds’





✅ Correct Answer: 1

What is the index value of “Ravi” in the following Series? import pandas as pd S1 = pd.Series["Ram", "Raju", "Ravi", "Ramesh", "Rishabh"]





✅ Correct Answer: 2

An output of series ‘S1’ is shown below, are the data values in ‘S1 and _ are the data labels in ‘S1’. Output: Feb 2 Mar 3 Apr 4 dtype: int64





✅ Correct Answer: 2

What is the data type of given series ‘S1’? import pandas as pd S1=pd.Series('a', index=(2.0, 3.0, 4.0, 5.0)) print(S1)





✅ Correct Answer: 3

How many elements will be there in given series ‘S1’? import pandas as pd S1=pd.Series('python practice') print(S1)





✅ Correct Answer: 2

Two common ways for accessing the elements of a series are _________ and ____





✅ Correct Answer: 3

How many times value ’10’ will be displayed in the given series ‘S1’? import pandas as pd S1=pd.Series(10, index = range(1, 10, 3)) print(S1)





✅ Correct Answer: 3

Which of the following statement is correct to add NaN value in series?





✅ Correct Answer: 3

Which of the following is parameter of Series( ) function?





✅ Correct Answer: 4

What is the data type of series ‘S1’ given below ? S1=pd.Series([11, 12.5, “ok”])





✅ Correct Answer: 3

Which of the following attribute of Series is used to set the name of Series object?





✅ Correct Answer: 2

Which of the following attribute is used to check NaN value in Series?





✅ Correct Answer: 2

Which of the following attribute of Series returns the tuple?





✅ Correct Answer: 2

What type of error is returned, when the length of index and the length of data in Series() function is not same?





✅ Correct Answer: 2

Write a statement to display 12.5 as output using positional indexing. import pandas as pd S1=pd.Series([11, 12.5, None, 6], index=["J","F","M","A"])





✅ Correct Answer: 4

Can a Series have duplicate index value?





✅ Correct Answer: 1

Rosy wants to display the series ‘S1’ in reverse order. Help her to find the correct code.





✅ Correct Answer: 2

Number of students in each section of class 9th is stored in series ‘S1’. Write a statement to change the value of section ‘A’ and ‘B’ to 50. A 41 B 44 C 40 D 42 E 47





✅ Correct Answer: 3

S1[0 : 2] = 50





✅ Correct Answer: 4

Series ‘S1’ has five values with index value (0, 1, 2, 3, 4) and series ‘S2’ has five values with index (2, 3, 4, 5, 6). What will be the total number of values in ‘S3’ if S3 = S1 + S2





✅ Correct Answer: 3

Raman performed addition of series ‘S1’ and ‘S2’ and store the result in series ‘S3’. Both the series ‘S1’ and ‘S2’ have five mismatching index value. How many NaN will be there in ‘S3’?





✅ Correct Answer: 4

Which of the following statement return Boolean result? import pandas as pd S1=pd.Series([11, 12, 5, 6,9]) print(S1) #Statement 1 print(S1>7) #Statement 2 print(S1[S1>7]) #Statement 3





✅ Correct Answer: 2

Which of the following statement return Filtered result? import pandas as pd S1=pd.Series([11, 12, 5, 6,9]) print(S1) #Statement 1 print(S1>7) #Statement 2 print(S1[S1>7]) #Statement 3





✅ Correct Answer: 3

Amit is working in an IT firm as Data Manager. He stored the salary of all employees in Series named “Empser”. His Boss asked him to filter the employees whose salary is more than 20000. Help him to find the correct code. Sample of data stored is shown below. 0 25000 1 20000 2 21000 3 30000





✅ Correct Answer: 3

_________ function is used to sort a Series object on the basis of values.





✅ Correct Answer: 2

Anshuman wants to create a series named ‘S1’. He has written the following codes. His friend Shubham checked the code and said that one of the code given below is not working. As a friend of Anshuman, help him to find the incorrect code. a. S1=pd.Series(data=[11, 12, 5, 6,9],index=[1,2,3,4,5])





✅ Correct Answer: 4

Sonal is a class XII student. She is learning “Series” in Python. She is confused in “parameter of Series( ) function”. Help her to find the incorrect parameter.





✅ Correct Answer: 3

Roshan has written few points about iloc( ) function of Series in Python. His friend Suman told that one of the written statement is not correct. Help him to find the incorrect statement.





✅ Correct Answer: 2

print(S1[-1]) will return ___________ #’S1′ is a series





✅ Correct Answer: 3

>>> S1[1:3] = 50 will update the value of ___________ elements





✅ Correct Answer: 2

_________ statement will assigns a name to the Series ‘S1’.





✅ Correct Answer: 1

Write the output of the following: import pandas as pd S1=pd.Series(data=[11, 12, None, 6,9,7],index=[1,12,3,4,2,4]) print(S1.count())





✅ Correct Answer: 3

While performing mathematical operations on series, index matching is implemented and all missing values are filled in with ___________ by default





✅ Correct Answer: 1

Mr. Kumar is working in an IT company. He stored the salaries of all the employees of January month in Series ‘Jan_Sal’ and salaries of February month in Series ‘Feb_Sal’. Now he wants to add the salaries of both months. He has written the following statement. Identify the correct one.





✅ Correct Answer: 1

Which of the following method is used to subtract the two series?





✅ Correct Answer: 4