Python for Data Science NPTEL | Week 3

Session: JAN-APR 2024/JULY-DEC 2023

Course name: Python For Data Science

Course Link: Click Here

These are NPTEL Python for Data Science Assignment 3 Answers


Q1. Which of the following is the correct approach to fill missing values in case of categorical variable?
Mean
Median
Mode
None of the above

Answer: Mode


Q2. Of the following set of statements, which of them can be used to extract the column Type as a separate dataframe?
df_cars[[‘Type’]]
df_cars.iloc[[:, 1]
df_cars.loc[:, [‘Type’]]
None of the above

Answer: a, c


Q3. The method df_cars.describe() will give description of which of the following column?
Car name
Brand
Price (in lakhs)
All of the above

Answer: Price (in lakhs)


These are NPTEL Python for Data Science Assignment 3 Answers


Q4. Which pandas function is used to stack the dataframes vertically?
pd.merge()
pd.concat()
join()
None of the above

Answer: pd.concat()


Q5. Which of the following are libraries in Python?
Pandas
Matplotlib
NumPy
All of the above

Answer: All of the above


Q6. Which of the following variable have null values?
ID
Company
Review Date
Rating

Answer: Review Date


These are NPTEL Python for Data Science Assignment 3 Answers


Q7. Which of the following countries have maximum locations of cocoa manufacturing companies?
U.K.
U.S.A.
Canada
France

Answer: U.S.A.


Q8. After checking the data summary, which feature requires a data conversion considering the data values held?
Rating
Review date
Company
Bean origin

Answer: Review date


Q9. What is the maximum rating of chocolates?
1.00
5.00
3.18
4.00

Answer: 5.00


Q10. What will be the output of the following code?
[bool, int, float, float, str]
[str, int, float, float, str]
[bool, int, float, int, str]
[bool, int, int, float, str]

Answer: [bool, int, float, float, str]


These are NPTEL Python for Data Science Assignment 3 Answers

More Weeks of Python for Data Science: Click here

More Nptel Courses: Click here


Session: JAN-APR 2023

Course Name: Python for Data Science

Course Link: Click Here

These are NPTEL Python for Data Science Assignment 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 the above

Answer: c. Mode


Assume a pandas dataframe df_cars which when printed is as shown below. Based on this information, answer questions 2 and 3.

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


These are NPTEL Python for Data Science Assignment 3 Answers


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()


These are NPTEL Python for Data Science Assignment 3 Answers


Q5. Which of the following are liabraries in Python?
a. Pandas
b. Matplotlib
c. NumPy
d. All of the above

Answer: d. All of the above


Read the comma-separated values file hotel bookings.csv as a dataframe data hotel and answer questions 6 – 8. Please refer to Hotel Bookings Data Description.pdf for data and variable description.

Q6. Choose the appropriate command(s) to filter those booking details whose reservation-status are a No-show?

a.

b.

c.

d.

Answer: b, d


These are NPTEL Python for Data Science Assignment 3 Answers


Q7. From the same data, find how many bookings were not canceled in the year 2017?
a. 9064
b. 6231
c. 9046
d. None of the above

Answer: a. 9064


Q9. From the total bookings that were made in 2017 and not canceled, which month had the highest number of repeated guests?
a. July
b. February
c. January
d. None of the above

Answer: a. July


These are NPTEL Python for Data Science Assignment 3 Answers


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

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. [bool, int, float, float, str]


Q10. Which command is used to generate the plot shown below?

a. plt.plot(x, linestyle = “-”)
b. plt.plot(x, linestyle = “–”)
c. plt.plot(x, linestyle = “-.”)
d. plt.plot(x, linestyle = “:”)

Answer: a. plt.plot(x, linestyle = “-”)


These are NPTEL Python for Data Science Assignment 3 Answers

More Weeks of Python for Data Science NPTEL: Click here

More NPTEL courses: https://progiez.com/nptel


Session: JULY-DEC 2022

Course name: Python for Data Science

Link to Enroll: Click Here

These are NPTEL Python for Data Science Assignment 3 Answers


Q1. Choose the appropriate command(s) to filter those booking details whose reservation_status are a No-show?
a. data_hotel_ns datahotel. loc[data_hotel.reservation_status=’No-Show’]
b. data_hotel_ns = data_hotel[ data _hotel. reservation_status = “No-Show’]
c. data hotel_ns = data_hotel. reservation_status.loc [data_hotel.isin([‘No-Show’])]
d. data_hotel_ns = data_hotel.loc [data hotel. reservation_status. isin([ No-Show’])]

Answer:b, d


Q2. From the same data, find how many bookings were not cancelled in the year 2017?

a. 9064
b. 6231
c. 9046
d. None of the above

Answer: a. 9064


Q3. From the total bookings that were made in 2017 and not cancelled, which month had the highest number of repeated guests?
a. July
b. February
c. January
d. None of the above

Answer: c. January


These are NPTEL Python for Data Science Assignment 3 Answers


Q4. Which of the following commands can be used to create a variable Flag, and set the values as Premium when the rating is equal to or greater than 3.25, and otherwise as Regular?
a. dt_cocoa[°Flag’] = [“Premium” if x 3.25 else “Regular” for x in dt_cocoa[‘Rating’ ]]
b. dt_cocoa[“Flag’] = [“Premium” if x 3.25 else “Regular” for x in dt_cocoa[ _` Rating ‘]]
c. dt_cocoa[“Flag”] = np.where(dt_cocoa[ “Rating”] < 3.25, “Regular”, “Premium”)
d. None of the above

Answer: b, c


Q5. Which instruction can be used to impute the missing values in the column Review Data from the dataframe dt_cocoa by grouping the records company–wise?

Answer: a


Q6. After checking the data summary, which feature requires a data conversion considering the data values held?
a. Rating
b. Review Date
c. Company
d. None of the above

Answer: b. Review Date


These are NPTEL Python for Data Science Assignment 3 Answers


Q7. What is the maximum average rating for the cocoa companies based out of Guatemala?
a. 43.
b. 53.
c. 42.
d. None of the above

Answer: c. 42.


Q8. 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()


These are NPTEL Python for Data Science Assignment 3 Answers


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

a. df_weather[[_`Direction ‘ ]]
b. df_weather.iloc[:,0]
c. df_weather.loc[:.[ ‘Direction ‘]]
d. None of the above

Answer: a, b


These are NPTEL Python for Data Science Assignment 3 Answers


Q10. Which one of these students’ average score across all subjects was the lowest? Which subject has the highest average score across students?

a. Harini, Maths
b. Sathi, Maths
c. Harini, Physics
d. Rekha, Maths

Answer: b. Sathi, Maths


These are NPTEL Python for Data Science Assignment 3 Answers

More NPTEL course answers: https://progiez.com/nptel


These are NPTEL Python for Data Science Assignment 3 Answers
The content uploaded on this website is for reference purposes only. Please do it yourself first.