Data Science for Engineers | Week 1

Session: JULY-DEC 2023

Course Name: Data Science for Engineers

Course Link: Click Here

These are NPTEL Data Science for Engineers Assignment 1 Answers


Q1. Which of the following variable names are INVALID in R?
1_variable
variable_1
_variable
variable@

Answer: 1_variable, _variable, variable@ [A, C, D]


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

Answer: list all objects in our working environment


These are NPTEL Data Science for Engineers Assignment 1 Answers


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

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: print(patient list[[3]][2])


Q4. The output of the code given below is
a)
b)
c)
d) Code will throw an error.

Answer: b) [1] 4


These are NPTEL Data Science for Engineers Assignment 1 Answers


Q5. What is the output of following code?
double
integer
list
None of the above

Answer: double


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: True


These are NPTEL Data Science for Engineers Assignment 1 Answers


Q7. What is the output of following code?
6
4
2
8

Answer: 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’))

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: student data[“student dept”]= c(“Commerce”,“Biology”, “English”,“Tamil”)


These are NPTEL Data Science for Engineers Assignment 1 Answers


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: student data[[3]][4]


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


These are NPTEL Data Science for Engineers Assignment 1 Answers


More Solutions of Data Science for Engineers: Click Here

More Nptel Courses: Click here


Q1) 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. list all files in our working directory

Answer: b. list all objects in our working environment


Q2) Consider the following code:

image 11

If a room temperature of 20 degree Celsius is input to the above code, choose the output displayed:
a. “The room is chilly. Please turn the heater on!”
b. “The room is warm” “Enjoy the stay!”
c. “The room is hot” “Please turn the air conditioning on!”
d. None of the above

Answer: b. “The room is warm” “Enjoy the stay!”


These are NPTEL Data Science for Engineers Assignment 1 Answers


Q3) Consider the code below to create a dataframe city_data:

image 12

Choose the correct answer based on the output expected on running the below code.

image 13

a. In the column weather in dataframe city_data, “Rain” is replaced by “Snowy”
b. In the column name in dataframe city_data, “City C” is replaced by “Snowy”
c. No change occurs to the entries in the dataframe city_data
d. The code raises an error

Answer: a. In the column weather in dataframe city_data, “Rain” is replaced by “Snowy”


These are Data Science for Engineers Week 1 Assignment Answers


Q4) Consider the code given below.

image 10

Choose the correct command to access the variable “Cloudy”
a. city_weather[[4]][2]
b. city_weather[[5]]
c. city_weather[[2]][2]
d. None of the above

Answer: a. city_weather[[4]][2]


These are NPTEL Data Science for Engineers Assignment 1 Answers


Q5) Consider the following code.
A = matrix(c(1:42), nrow = 6, ncol = 7, byrow = T)
B = A[-2,]
Based on the output of the above code, choose the correct options from the following

a. B is a matrix consisting of only elements of the second row of matrix A
b. B is a matrix consisting of same elements as that of A
c. The code raises an error
d. B is a matrix consisting of all elements of A excluding the second row

Answer: a. B is a matrix consisting of only elements of the second row of matrix A


Q6) The parameter “collapse” in the function paste()
a. adjusts the display of the string to left, right or center
b. add space in between two strings
c. eliminates the space in between two strings
d. eliminates the space within two words in a string

Answer: b. add space in between two strings


These are NPTEL Data Science for Engineers Assignment 1 Answers


Q7) Consider the following code in R.

image 14

If we supply 4 as an argument to the function find.function, after executing the above code, the result displayed would be
a. the numbers “1,2,3,4”
b. the numbers “1,4,9,16”
c. the number “4”
d. None of the above

Answer: b. the numbers “1,4,9,16”


Q8) The operator %in% is used for
a. multiplication of a matrix with its transpose
b. generating a sequence of numbers in a vector
c. identifying if an element belongs to a vector
d. none of the above

Answer: c. identifying if an element belongs to a vector


These are NPTEL Data Science for Engineers Assignment 1 Answers


Q9) The output of compiling and executing the following code in R would be

image 15

a. The term “Green” “apple” printed 5 times.
b. The term “Green apple” printed 3 times.
c. The term “Green” printed 4 times
d. The term “Green” “apple” printed 4 times.

Answer: d. The term “Green” “apple” printed 4 times.


Q10) The “next” statement in R programming is useful
a. for skipping the current iteration of a loop without terminating it.
b. for terminating the current iteration of a loop.
c. for evaluating the current iteration of a loop without terminating it.
d. None of the above

Answer: a. for skipping the current iteration of a loop without terminating it.


These are NPTEL Data Science for Engineers Assignment 1 Answers

More Solutions of Data Science for Engineers: Click Here

More Nptel Courses: Click here


NPTEL Data Science for Engineers Assignment 1 Answers

This content is uploaded for study, general information, and reference purpose only.