Data Science for Engineers Week 1 NPTEL Assignment Answers 2025

NPTEL Data Science for Engineers Week 1 Assignment Answers 2025

1. Which of the following variable names are INVALID in R?
a. 1_variable
b. variable_1
c. _variable
d. variable@

Answer: a. 1_variable, c. _variable, d. variable@

Explanation:

  • Variable names in R cannot start with a digit1_variable is invalid.
  • Variable names should not start with an underscore_variable is invalid.
  • Special characters like @ are not allowed in variable names → variable@ is invalid.
  • variable_1 is valid.

2. The function ls() in R will
a. set a new working directory path
b. list all objects in our working environment
c. display the path to our working directory
d. None of the above

Answer: b. list all objects in our working environment

Explanation:
ls() is used to list all the variables and functions currently defined in the environment.


3. Which of the following command is used to access the value “Shyam”?
a. print(patient_list[3][2])
b. print(patient_list[[3]][1])
c. print(patient_list[[3]][2])
d. print(patient_list[[2]][2])

Answer: c. print(patient_list[[3]][2])

Explanation:

  • [[3]] accesses the third element of the list.
  • [2] accesses the second element within that third list item, which is "Shyam".

4. The output of the code given below is

Code will throw an error

Answer: c.

Explanation:
(Without code, can’t give exact explanation. If you provide code, I can elaborate.)


5. What is the output of following code?

a. double
b. integer
c. list
d. None of the above

Answer: a. double

Explanation:
By default, R treats numeric literals (like 3.14 or 5) as double unless specifically defined as integer using L (e.g., 5L).


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

a. True
b. False

Answer: a. True

Explanation:
The reshape2 package uses melt() to transform data into long format and cast() (or dcast()/acast()) to reshape it back.


7. What is the output of following code?

a. 6
b. 4
c. 2
d. 8

Answer: b. 4

Explanation:
(Explanation depends on code. Please share the exact code for better clarity.)


8. Choose the correct command to add a column named student_dept to the dataframe student_data.
a. student_data$student_dept = c("Commerce", "Biology", "English", "Tamil")
b. student_data["student_dept"]= c("Commerce", "Biology", "English", "Tamil")
c. student_dept= student_data[c("Commerce", "Biology", "English", "Tamil")]
d. None of the above

Answer: a and b

Explanation:
Both a and b correctly add a new column to the dataframe.

  • $ adds a column by name.
  • df["new_col"] adds it using the name as string.

9. Choose the correct command to access the element “Tamil” in the dataframe student_data.
a. student_data[[4]]
b. student_data[[4]][3]
c. student_data[[3]][4]
d. None of the above

Answer: c. student_data[[3]][4]

Explanation:

  • [[3]] accesses the third column.
  • [4] accesses the fourth value in that column.
    Hence, "Tamil" is correctly accessed this way.

10. The command to check if a value is of numeric data type is ____
a. typeof()
b. is.numeric()
c. as.numeric()
d. None of the above

Answer: b. is.numeric()

Explanation:

  • is.numeric() checks if the data is numeric (returns TRUE/FALSE).
  • as.numeric() converts values to numeric type.
  • typeof() returns the data type, not just a boolean check.