Python for Data Science | NPTEL | Week 3 Answers

This set of MCQ(multiple choice questions) focuses on the Python for Data Science NPTEL Week 3 Answers

You should practice these questions to improve fundamentals of Data Science needed for various interviews (like company interview, campus interview, walk-in interview), entrance exams, placements and other competitive exams. All the questions in this particular section are based on only “Python for Data Science NPTEL Week 3 Answers“.

Course layout

Week 1: Basics of Python Spyder
Week 2: Sequence data types & associated operations
Week 3: Data frames
Week 4: Case study

NOTE: You can check your answer immediately by clicking show answer button. Moreover, this set of “Python for Data Science NPTEL Week 3 Answers” contains 10 questions.

Now, start attempting the quiz.

Python for Data Science NPTEL Week 3 Answers

Q1. Which of the following is the correct approach to fill missing values in case of categorical variable?

a) Mean
b) Median
c) Mode
d) None of these

Answer: c) Mode

Python for Data Science NPTEL Week 3 Answers

Q2. Of the following set of statements, which of them can be used to extract the column Type as a separate dataframe?

a) df_cars[[‘Type’]]
b) df_cars.iloc[[:, 1]
c) df_cars.loc[:, [‘Type’]]
d) None of the above

Answer: a), c)

Q3. The method df_cars.describe() will give description of which of the following column?

a) Car name
b) Brand
c) Price (in lakhs)
d) All of the above

Answer: c) Price (in lakhs)

Q4. Which pandas function is used to stack the dataframes vertically?

a) pd.merge()
b) pd.concat()
c) join()
d) None of the above

Answer: b) pd.concat()

Python for Data Science NPTEL Week 3 Answers

Q5. Which of the following are libraries in Python?

a) Pandas
b) Matplotlib
c) NumPy
d) All of the above

Answer: d) All of the above

Q6. Which of the following variable have null values?

a) ID
b) Company
c) Review Date
d) Rating

Answer: c) Review Date

Q7. Which of the following countries have maximum locations of cocoa manufacturing companies?

a) U.K.
b) U.S.A.
c) Canada
d) France

Answer: b) U.S.A.

Python for Data Science NPTEL Week 3 Answers

Q8. After checking the data summary, which feature requires a data conversion considering the data values held?

a) Rating
b) Review date
c) Company
d) Bean origin

Answer: b) Review date

Q9. What is the maximum rating of chocolates?

a) 1.00
b) 5.00
c) 3.18
d) 4.00

Answer: b) 5.00

Q10. What will be the output of the following code?

import numpy as np
B = [True, 2, 3.0, np.nan, "False"]
[type(i) for i in B]

a) [bool, int, float, float, str]
b) [str, int, float, float, str]
c) [bool, int, float, int, str]
d) [bool, int, int, float, str]

Answer: a)

Python for Data Science NPTEL Week 3 Answers

Python for Data Science NPTEL Week 3 Answers

Q1. Data from the file “brand_data.csv“ has to be loaded into a pandas dataframe. A snippet of the data is shown below:
0, 1, 2, 2
brand, type, cost, price
BR1, clnr, 12, 15
BR2, util, 23, 34
BR3, lux, 189, 191
BR4, txtl, 150, 130

What is the right instruction to read the file into a dataframe df_brand with 4 separate columns?

a) pd.read_csv(“brand_data.csv”, index_col=0, header = 1)
b) df_brand = pd.read_csv(“brand_data.csv”, header = 1)
c) df_brand = pd.read_csv(“brand_data.csv”, header = None)
d) df_brand = pd.read_table(“brand_data.csv”, delimiter = ‘,’, header = 1)

Answer: b), d)

Q2. For the same file above “brand_data.csv“, which parameter in pd.read_csv will help to load dataframe df_brand with the selected columns as shown below?

In [17]: df_brand
out[17]:
brand price
0 BR1 15
1 BR2 34
2 BR3 191
3 BR4 130

a) index_col
b) skiprows
c) usecols
d) None of the above

Answer: c)

Q3. Data from the file “weather.xlsx“ has to be loaded into a pandas dataframe df_weather which when printed is as shown below:

In [38]: df_weather
Out[38]:
   Direction  Temperature  Windspeed Humidity
0       East           49         10       78
1       West           54          5       80
2      North           35          8       92
3      South           42         15       70

Of the following set of statements which of them can be used to move the column “Direction” into a separate dataframe

a) df_weather[[‘Direction’]]
b) df_weather[‘Direction’]
c) df_weather.loc[:, [‘Direction’]]
d) df_weather.iloc[:, 0]

Answer: a), c)

Q4. Referring to the same dataframe df_weather in Question(3), which statement/statements will help to print the last row from the dataframe?

a) print(df_weather.head(-1))
b) print(df_weather.tail(1))
c) print(df_weather[2:3])
d) print(df_weather.iloc[-1])

Answer: b), d)

Python for Data Science NPTEL Week 3 Answers

Q5. In reference to the same dataframe df_weather, we add an additional column ‘Hot_day’ to determine whether the day is hot or not based on the values in the Temperature column. What will the print statement derive?
df_weather[‘Hot_dat’] = np.where(df_weather[‘Temperature’] > 40, True, False)
print(df_weather[‘Hot_day’][2])

a) True
b) SyntaxError
c) False
d) None of the above

Answer: c)

Q6. What statement would give the number of columns in a dataframe df?

a) len(df.columns)
b) len(df)
c) df.size
d) All of the above

Answer: a)

Q7. A file “Students.csv” contains the attendance and total scores of three separate students. This data is loaded into a dataframe df_study and a pandas crosstab is applied on the same dataframe which results in the following output.

Subject
Person
ChemistryMathsPhysicsAll
Harini90.0094.0083.0089.00
Rekha92.0085.0095.0090.67
Sathi74.0081.0081.0079.67
All85.3386.6786.3386.44

Which student scored the maximum average score of all three subjects? Which subject has the best average score for all three students?

a) Harini,Chemistry
b) Rekha,Physics
c) Harini,Physics
d) Rekha,Maths

Answer: d)

Python for Data Science NPTEL Week 3 Answers

Q8. The following histogram shows the number of books read in a year:

Python for Data Science NPTEL Week 3 Answers

Find the mean and median in the above histogram.

a) 7, 8
b) 8, 9
c) 8.5, 7
d) 8, 8
e) None of the above

Answer: d)

Q9. For the following box plot, which among the given options are the median and the outlier?

a) 15, 52
b) 22, 52
c) 13.5, 29
d) 25, 50

Answer: b)

Q10. A dataframe df_logs has the following data.

All the NaN / Null values in the column C1 can be replaced by zero value by executing which of the following statements?

a) df_logs[‘C1’].fillna(0,inplace = True)
b) df_logs.fillna(0,inplace = True)
c) df_logs.fillna(0,inplace = False)
d) df_logs[‘C1’].fillna(df_logs[‘B1’],inplace = True)

Answer: a)

Python for Data Science NPTEL Week 3 Answers

<< Prev- Python for Data Science Week 2 Assignment Solutions

>> Next- Python for Data Science Week 4 Assignment Solutions


Programming in Java NPTEL week 1 quiz answers

Nptel – Deep Learning assignment solutions

The above question set contains all the correct answers. But in any case, you find any typographical, grammatical or any other error in our site then kindly inform us. Don’t forget to provide the appropriate URL along with error description. So that we can easily correct it.

Thanks in advance.

For discussion about any question, join the below comment section. And get the solution of your query. Also, try to share your thoughts about the topics covered in this particular quiz.

Leave a Comment

Your email address will not be published. Required fields are marked *