## NPTEL Data Science For Engineers Week 1 Assignment Answers 2024

Q1. Which of the following variable names are INVALID in R?

1_variable

variable_1

_variable

variable@

Answer:-For Answer Click Here

Q2. The function ls() in R will

set a new working directory path

list all objects in our working environment

display the path to our working directory

None of the above

Consider the following code snippet. Based on this, answer questions 3 and 4.

Answer:-For Answer Click Here

Q3. Which of the following command is used to access the value “Shyam”?

print(patient_list[3][2])

print(patient_list[[3]][1])

print(patient_list[[3]][2])

print(patient_list[[2]][2])

Answer:-

Q4. The output of the code given below is

Code will throw an error.

Answer:-For Answer Click Here

Q5. What is the output of following code?

double

integer

list

None of the above

Answer:-

Q6. State whether the given statement is True or False.

The library reshape2 is based around two key functions named **melt** and **cast**.

True

False

Answer:-For Answer Click Here

Q7. What is the output of following code?

6

4

2

8

Answer:-

**Create the data frame using the code given below and answer questions 8 and 9.**

student_data = data.frame(student_id=c(1:4), student_name=c(‘Ram’,‘Harish’,‘Pradeep’,‘Rajesh’))

Q8. Choose the correct command to add a column named **student dept** to the dataframe **student data**.

student_datastudent dept=c(“Commerce”, “Biology”, “English”, “Tamil”)

student_data[“student dept”]= c(“Commerce”,“Biology”, “English”,“Tamil”)

student_dept= student data[c(“Commerce”,“Biology”,“English”,“Tamil”)]

None of the above

Answer:-For Answer Click Here

Q9. Choose the correct command to access the element **Tamil** in the dataframe **student_data**.

student_data[[4]]

student_data[[4]][3]

student_data[[3]][4]

None of the above

Answer:-

Q10. The command to check if a value is of numeric data type is ________.

typeof()

is.numeric()

as.numeric()

None of the above

Answer:-For Answer Click Here

## NPTEL Data Science For Engineers Week 4 Assignment Answers 2023

**1. Let f(x)=x3+3×2−24x+7. Select the correct options from the following:**

x=2 will give the maximum for f(x).

x=2 will give the minimum for f(x).

Maximum value of f(x) is 87.

The stationary points for f(x) are 2 and 4.

Answer :-For AnswerClick Here

2. Find the gradient of f(x,y)=x2y at (x,y)=(1,3) .

∇f=[16]

∇f=[61]

∇f=[69]

∇f=[33]

Answer :-

**3. Find the Hessian matrix for f(x,y)=x2y at (x,y)=(1,3).**

∇2f=[3220]

∇2f=[3330]

∇2f=[6220]

∇2f=[6330]

Answer :-For AnswerClick Here

**4. Let f(x,y)=−3×2−6xy−6y2. The point (0,0)is a**

saddle point

maxima

minima

Answer :-

**6. For which numbers b is the matrix A=[1bb9] positive definite?**

−3<b<3

b=3

b=−3

−3≤b≤3

Answer :-

**6. Consider f(x)=x3−12x−5. Which among the following statements are true?**

f(x)is increasing in the interval (−2,2).

f(x)is increasing in the interval (2,∞).

f(x)is decreasing in the interval (−∞,−2).

f(x)is decreasing in the interval (−2,2).

Answer :-

**7. Consider the following optimization problem:**

4×3+21×2+10x−17=0

12×2+42x+10=0

12×2+42x+10>0

12×2+42x+10<0

Answer :-

**8. In optimization problem, the function that we want to optimize is called**

Decision function

Constraints function

Optimal function

Objective function

Answer :-

**9. The optimization problem minx f(x) can also be written as maxx f(x).**

True

False

Answer :-

**10. Gradient descent algorithm converges to the local minimum.**

True

False

Answer :-

## NPTEL Data Science For Engineers Week 3 Assignment Answers 2023

**A six sided die is marked ‘1’ on one face, ‘2’ on two of its faces, and ‘3’ on the remaining three faces. The die is thrown twice. Let X denotes the total score in two throws.Based on the above information, answer questions (1), (2).**

**1. Find the value of P(X>2.5|X<5). (Enter the answer correct to 2 decimal places).**

Answer :-

**2. Find the expected value of X.**

Answer :-For AnswerClick Here

**3. Suppose X ∼ Normal(μ,4). For n=20 iid samples of X, the observed sample mean is 5.2. What conclusion would a z-test reach if the null hypothesis assumes μ=5 (against an alternative hypothesis μ≠5) at a significance level of α=0.05? **Use F−1z(0.025)=−1.9599

- Accept H0
- Reject H0

Answer :-

**4. A pharmaceutical company is testing a new drug. The probability that a patient experiencing a side effect from this drug is 0.100.10. If the drug is given to 55 patients, what is the probability that more than 1 patient will experience the side effect? (Enter the answer correct to 22 decimal places.)**

Answer :-

**5. Suppose X∼Normal(μ,9)(μ,9). For n=100 iid samples of X, the observed sample mean is 11.811.8. What conclusion would a z-test reach if the null hypothesis assumes μ=10.5μ (against an alternative hypothesis μ≠10.5μ≠10.5)?**

- Accept H0 at a significance level of 0.10.
- Reject H0 at a significance level of 0.10.
- Accept H0 at a significance level of 0.05.
- Reject H0 at a significance level of 0.05.

Answer :-

**6. Let X and Y be two independent random variables with Var(X)=9 and Var(Y)=3, find Var(4X−2Y+6).**

- 100
- 140
- 156
- None of the above

Answer :-

**7. The correlation coefficient of two random variable X and Y is −14, their variance is given by 3and 5. Compute Cov(X,Y).**

- -0.854
- 0.561
- -0.968
- None of the above

Answer :-

**8. A sample of N observations are independently drawn from a normal distribution. The sample variance follows**

- Normal distribution
- Chi-square with N degrees of freedom
- Chi-square with N−1 degrees of freedom
- t-distribution with N−1 degrees of freedom

Answer :-For AnswerClick Here

**9. A car manufacturer purchases car batteries from two different suppliers. Supplier X provides 55% of the batteries and supplier Y provides the rest. 5%5% of all batteries from supplier X are defective and 4% of all batteries from supplier Y are defective. You select a battery from the bulk and you found it to be defective. What is the probability that it is from Supplier X?**

- 0.0455
- 0.455
- 0.0275
- 0.018

Answer :-

**10. Find the t-statistic for the sample data, given that the population mean of the distribution is 8.**

- -3.155
- 8.33
- -2.99
- None of the above

Answer :-

## NPTEL Data Science For Engineers Week 2 Assignment Answers 2023

**1. Are the vectors [−2 4], [7 −2] and [3 −6] linearly independent?**

- Yes
- No

Answer :-b

**2. Does the set, S={(1,1),(1,2)} spans R ^{2}?**

- Yes
- No

Answer :-a

3. **Consider the following system of linear equations of the form Ax=b:1 2x−3y+6z=14 x+y−2z=−3Which among the following are correct?**

- [ 1−4 0 ] is a solution to Ax=b
- [ 0 2 1 ] is a solution to Ax=b
- [ 1 −4 0 ] is a solution to Ax=0
- [ 0 2 1 ] is a solution to Ax=0

Answer :-a, d

**Consider the following systerm of linear equation:**x+y+z=−2

x+2y−z=1

2x+ay+bz=2

**4. Find the conditions on a and b for which the above system has no solution.**

- 2a+b−6=0
- a≠4, 2a+b−6= 0
- a=4, b = −2
- 2a+b−6 ≠ 0

Answer :-b

**5. Find the conditions on a and b for which the above system has a unique solution.**

- 2a+b−6=0
- a≠4, 2a+b−6= 0
- a=4, b = −2
- 2a+b−6 ≠ 0

Answer :-d

**6. Find the conditions on a and b for which the above system has infite number of solutions.**

- 2a+b−6=0
- a≠4, 2a+b−6= 0
- a=4, b = −2
- 2a+b−6 ≠ 0

Answer :-c

**7. Identify the number of free variable from the above rwo echelon matrix.**

- 0
- 1
- 2
- 3

Answer :-b

**8. Which among the following is correct for the above system Ax= b?**

- It has infinite number of solutions.
- It has a unique solution.
- It has no solution.

Answer :-a

**9. For what values of a are matrix **

** not invertible? **

- a=1
- a=−2
- a=−1
- a=2

Answer :-b, c

**10. Which among the following is true for the determinant of a matrix?**

- The determinant of a diagonal matrix is the product of its diagonal entries.
- If one row of a matrix is a scalar multiple of another, the determinant is 1.
- If one row of a matrix is a scalar multiple of another, the determinant is 0.
- The determinant of a permutation matrix can only be 1.

Answer :-a, c

**11. Which among the following are the eigenvalues of matrix**

- 1, 3, −3
- 1, 3, 3
- −1, 3, 3
- 1, −3, −3

Answer :-d

Answer :-2

**13. Let A= [−1 2 2]. Suppose the eighen values corresponding to AA ^{T} are a,b and c, then find the value of ab+bc+ca.**

- 9
- 0
- 81
- 18

Answer :-b

## NPTEL Data Science For Engineers Week 1 Assignment Answers 2023

**1. Which of the following variable names are INVALID in R?**

- 1_variable
- variable_1
- _variable
- variable@

Answer :- a. 1_variabled. variable@In R, variable names must follow certain rules and conventions. The valid variable names in R can only contain letters (a-z, A-Z), numbers (0-9), and dots (.) or underscores (_). Variable names cannot start with a number or contain special characters other than dots or underscores.

**2. The function ls() in R will**

- set a new working directory path
- list all objects in our working environment
- display the path to our working directory
- None of the above

Answer :- b. list all objects in our working environmentls() stands for "list objects" and is used to display the names of objects (variables, functions, etc.) that are currently present in the working environment in R. It does not change the working directory or display the path to the working directory. Instead, it lists the objects available in the current R session.

**Consider a following code snippet. Based on this, answer questions 3 and 4.**

**3. Which of the following command is used to access the value “Shyam”?**

- print(patient list[3][2])
- print(patient list[[3]][1])
- print(patient list[[3]][2])
- print(patient list[[2]][2])

Answer :- c. print(patient_list[[3]][2])In R, double square brackets [[ ]] are used to extract elements from a list. The first index [[3]] selects the third element of the list, which is itself another list. Then, the second index [2] selects the second element from this inner list, which is "Shyam". Therefore, patient_list[[3]][2] will give you the value "Shyam".

**4**. **The output of the code given below is**

d. Code will throw an error.

Answer :- c.

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

- double
- integer
- list
- None of the above

Answer :- a. double

**6. State whether the given statement is True or False.The library reshape2 is based around two key functions named melt and cast.**

- True
- False

Answer :- True.The statement is true. The library reshape2 in R is built around two key functions: melt and dcast (formerly known as acast). These functions are used for reshaping data from wide to long format and vice versa. The melt function is used to transform data from a wide format to a long format, while dcast is used to transform data from a long format to a wide format.

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

- 6
- 4
- 2
- 8

Answer :- b. 4

**Create the data frame using the code given below and answer questions 8 and 9.**

student data = data.frame(student id=c(1:4), student name=c(‘Ram’,‘Harish’,‘Pradeep’,‘Rajesh’))

**8. Choose the correct command to add a column named student_dept to the dataframe student_data.**

- student datastudent dept=c(“Commerce”, “Biology”, “English”, “Tamil”)
- student data[“student dept”]= c(“Commerce”,“Biology”, “English”,“Tamil”)
- student dept= student data[c(“Commerce”,“Biology”,“English”,“Tamil”)]
- None of the above

Answer :- a. student_data$student_dept = c("Commerce", "Biology", "English", "Tamil")b. student data[“student dept”]= c(“Commerce”,“Biology”, “English”,“Tamil”)

**9. Choose the correct command to access the element Tamil in the dataframe student_data**

- student data[[4]]
- student data[[4]][3]
- student data[[3]][4]
- None of the above

Answer :-student_data[[3]][4]In R, double square brackets [[ ]] are used to extract elements from a list or dataframe. In this case, student_data[[3]] extracts the third column (which is a vector containing "Commerce", "Biology", "English", "Tamil"), and then [4] is used to access the fourth element in that vector, which is "Tamil". Therefore, student_data[[3]][4] will give you the value "Tamil".

**10. The command to check if a value is of numeric data type is _____.**

- typeof()
- is.numeric()
- as.numeric()
- None of the above

Answer :- is.numeric()The is.numeric() function in R is used to determine whether a given value is of numeric data type or not. It returns TRUE if the value is numeric and FALSE otherwise. For example: