**NPTEL Python For Data Science Assignment Answer**

## NPTEL Python For Data Science Week 4 Assignment Answer 2023

**1. Which of the following are regression problems? Assume that appropriate data is given.**

- Predicting the house price.
- Predicting whether it will rain or not on a given day.
- Predicting the maximum temperature on a given day.
- Predicting the sales of the ice-creams.

**Answer :- For Answer ****Click Here**

**2. Which of the followings are binary classification problems?**

- Predicting whether a patient is diagnosed with cancer or not.
- Predicting whether a team will win a tournament or not.
- Predicting the price of a second-hand car.
- Classify web text into one of the following categories: Sports, Entertainment, or Technology.

**Answer :- **For Answer **Click Here**

**3. If a linear regression model achieves zero training error, can we say that all the data points lie on a hyperplane in the (d+1)-dimensional space? Here, d is the number of features.**

- Yes
- No

**Answer :- **For Answer **Click Here**

**Read the information given below and answer the questions from 4 to 6:Data Description:**

An automotive service chain is launching its new grand service station this weekend. They offer to service a wide variety of cars. The current capacity of the station is to check 315 cars thoroughly per day. As an inaugural offer, they claim to freely check all cars that arrive on their launch day, and report whether they need servicing or not!

Unexpectedly, they get 450 cars. The servicemen will not work longer than the working hours, but the data analysts have to!

Can you save the day for the new service station?

How can a data scientist save the day for them?

He has been given a data set, ‘ServiceTrain.csv’ that contains some attributes of the car that can be easily measured and a conclusion that if a service is needed or not.

Now for the cars they cannot check in detail, they measure those attributes and store them in ‘ServiceTest.csv’

**Problem Statement:**

Use machine learning techniques to identify whether the cars require service or not

**Read the given datasets ‘ServiceTrain.csv’ and ‘ServiceTest.csv’ as train data and test data respectively and import all the required packages for analysis.**

**4. Which of the following machine learning techniques would NOT be appropriate to solve the problem given in the problem statement?**

- kNN
- Random Forest
- Logistic Regression
- Linear regression

**Answer :- **For Answer **Click Here**

**5. After applying logistic regression, what is/are the correct observations from the resultant confusion matrix?**

- True Positive = 29, True Negative = 94
- True Positive = 94, True Negative = 29
- False Positive = 5, True Negative = 94
- None of the above

**Answer :- **For Answer **Click Here**

**Prepare the data by following the steps given below, and answer questions 6 and 7.**

- Encode categorical variable, Service – Yes as 1 and No as 0 for both the train and test datasets.
- Split the set of independent features and the dependent feature on both the train and test datasets.
- Set random_state for the instance of the logistic regression class as 0.

**6. The logistic regression model built between the input and output variables is checked for its prediction accuracy of the test data. What is the accuracy range (in %) of the predictions made over test data?**

- 60 – 79
- 90 – 95
- 30 – 59
- 80 – 89

**Answer :- **For Answer **Click Here**

**7. How are categorical variables preprocessed before model building?**

- Standardization
- Dummy variables
- Correlation
- None of the above

**Answer :- **For Answer **Click Here**

**The Global Happiness Index report contains the Happiness Score data with multiple features (namely the Economy, Family, Health, and Freedom) that could affect the target variable value.**

Prepare the data by following the steps given below, and answer question 8

- Split the set of independent features and the dependent feature on the given dataset
- Create training and testing data from the set of independent features and dependent feature by splitting the original data in the ratio 3:1 respectively, and set the value for random_state of the training/test split method’s instance as 1

**8. A multiple linear regression model is built on the Global Happiness Index dataset ‘GHI_Report.csv’. What is the RMSE of the baseline model?**

- 2.00
- 0.50
- 1.06
- 0.75

**Answer :- **For Answer **Click Here**

**9. A regression model with the following function y=60+5.2x was built to understand the impact of humidity (x) on rainfall (y). The humidity this week is 30 more than the previous week. What is the predicted difference in rainfall?**

- 156 mm
- 15.6 mm
- -156 mm
- None of the above

**Answer :- **For Answer **Click Here**

**10. X and Y are two variables that have a strong linear relationship. Which of the following statements are incorrect?**

- There cannot be a negative relationship between the two variables.
- The relationship between the two variables is purely causal.
- One variable may or may not cause a change in the other variable.
- The variables can be positively or negatively correlated with each other

**Answer :- **For Answer **Click Here**

Course Name | Python For Data Science |

Category | NPTEL Assignment Answer |

Home | Click Here |

Join Us on Telegram | Click Here |

## NPTEL Python For Data Science Week 3 Assignment Answer 2023

**1. 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 :- **

**2. 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 :- **For Answer Click Here

**3. 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 :- **

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

- pd.merge()
- pd.concat()
- join()
- None of the above

**Answer :- **

**5. Which of the following are libraries in Python?**

- Pandas
- Matplotlib
- NumPy
- All of the above

**Answer :- **For Answer Click Here

**6. Which of the following variable have null values?**

- ID
- Company
- Review Date
- Rating

**Answer :- **

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

- U.K.
- U.S.A.
- Canada
- France

**Answer :- **For Answer Click Here

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

- Rating
- Review date
- Company
- Bean origin

**Answer :- **

**9. What is the maximum rating of chocolates?**

- 1.00
- 5.00
- 3.18
- 4.00

**Answer :- **

**10. 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 :- **For Answer Click Here

## NPTEL Python For Data Science Week 2 Assignment Answer 2023

**1. Which of the following object does not support indexing?**

- tuple
- list
- dictionary
- set

**Answer :- set**

**2. Given a NumPy array, arr = np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]), what is the output of the command, print(arr[0][1])?**

- [[1 2 3]

[4 5 6]

[7 8 9] - [1 2 3]
- [4 5 6]
- [7 8 9]

**Answer :- **[4 5 6]

**3. What is the output of the following code?**

- [2, 3, 4, 5]
- [0 1 2 3]
- [1, 2, 3, 4]
- Will throw an error: Set objects are not iterable.

**Answer :- **[1, 2, 3, 4]

**4. What is the output of the following code?**

**Answer :- c. ** [[ 0 1 2 3 4]
[ 5 6 7 8 9]
[10 11 12 13 14]]

**5. Which of the following code gives output My friend’s house is in Chennai?**

**Answer :- **place = 'Chennai'
print("My friend's house is in {}".format(place))
print("My friend's house is in {}".format("Chennai"))

**6. Let t1=(1,2, “tuple”,4) and t2=(5,6,7). Which of the following will not give any error after the execution?**

- t1.append(5)
- x=t2[t1[1]]
- t3=t1+t2
- t3=(t1,t2)
- t3=(list(t1), list(t2))

**Answer :- **x=t2[t1[1]]
t3=t1+t2
t3=(t1,t2)
t3=(
list(t1)
, list(t2))

**7. Let d={1:“Pyhton”,2:[1,2,3]}. Which among the following will not give the error after the execution?**

- d[2].append(4)
- x=d[0]
- d[“one”]=1
- d.update({‘one’ : 22})

**Answer :- **d[2]
.append(4)
d[
“one”]=1
d.
update({‘one’ : 2
})

**8. Which of the following data type is immutable?**

- list
- set
- tuple
- dictionary

**Answer :- tuple**
Tuples are immutable, meaning their elements cannot be changed after creation. Once a tuple is created, its contents remain fixed. In contrast, lists, sets, and dictionaries are mutable data types, which means their elements or values can be modified after they are created.

**9. student = {‘name’: ‘Jane’, ‘age’: 25, ‘courses’: [‘Math’, ‘Statistics’]}**

**Which among the following will return**

{‘name’: ‘Jane’, ‘age’: 26, ‘courses’: [‘Math’, ‘Statistics’], ‘phone’: ‘123-456’}?

{‘name’: ‘Jane’, ‘age’: 26, ‘courses’: [‘Math’, ‘Statistics’], ‘phone’: ‘123-456’}?

- student.update({‘age’ : 26})
- student.update({‘age’ : 26, ‘phone’: ‘123-456’})
- student[‘phone’] = ‘123-456’
- student.update({‘age’ : 26})
- None of the above

**Answer :- **student.update({‘age’ : 26, ‘phone’: ‘123-456’})
student[‘phone’] = ‘123-456’
student.update({‘age’ : 26})

**10. What is the output of the following code?**

**[‘M’, ‘A’, ‘H’, ‘E’, ‘S’, ‘H’]****[‘m’, ‘a’, ‘h’, ‘e’, ‘s’, ‘h’]****[‘M’, ‘a’, ‘h’, ‘e’, ‘s’, ‘h’]****[‘m’, ‘A’, ‘H’, ‘E’, ‘S’, ‘H’]**

**Answer :- a. **['M', 'A', 'H', 'E', 'S', 'H']

## NPTEL Python For Data Science Week 1 Assignment Answer 2023

**1. What is the output of the following code?**

- 36
- 121212
- 123
- Error: Invalid operation, unsupported operator ‘*’ used between ‘int’ and ‘str’

**Answer :- 121212**

**2. What is the output of the following code?**

- -1
- -2
- -1.28
- 1.28

**Answer :- -2**

**3. Consider a following code snippet. What is a data type of y?**

- int
- float
- str
- Code will throw an error.

**Answer :- str**

**4. Which of the following variable names are INVALID in Python?**

- 1_variable
- variable_1
- variable1
- variable#

**Answer :- 1_variable**, **variable#**

**5. While naming the variable, use of any special character other than underscore(_) ill throw which type of error?**

- Syntax error
- Key error
- Value error
- Index error

**Answer :- Syntax error**

**6. Let x = “Mayur”. Which of the following commands converts the ‘x’ to float datatype?**

- str(float,x)
- x.float()
- float(x)
- Cannot convert a string to float data type

**Answer :- Cannot convert a string to float data type**

**7. Which Python library is commonly used for data wrangling and manipulation?**

- Numpy
- Pandas
- scikit
- Math

**Answer :- Pandas**

**8. Predict the output of the following code.**

- 12.0
- 12
- 11.667
- 11

**Answer :- 12**

**9. Given two variables, j = 6 and g = 3.3. If both normal division and floor division operators were used to divide j by g, what would be the data type of the value obtained from the operations?**

- int, int
- float, float
- float, int
- int, float

**Answer :- float, float**

**10. Let a = 5 (101 in binary) and b = 3 (011 in binary). What is the result of the following operation?**

- 3
- 7
- 5
- 1

**Answer :- 1**

Course Name | Python For Data Science |

Category | NPTEL Assignment Answer |

Home | Click Here |

Join Us on Telegram | Click Here |