Are you searching for accurate and reliable NPTEL Week 1 assignment answers for the course “Data Science for Engineers”? You’ve landed at the right place! This article provides verified answers along with clear explanations for all the questions from Week 1 Answers, helping students prepare confidently and effectively.
1. Which of the following variable names
are INVALID in R?
Options:
a) 1_variable
b) variable_1
c) _variable
d) variable@
Answer:✅ a, c, d
Explanation:
In R, variable names:
- Cannot begin with a digit (so 1_variable is invalid)
- Cannot contain special characters like @
- Leading underscores (_variable) are not recommended and often cause issues
Only variable_1 is valid here.
2. The function ls() in R will
Options:
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
Explanation:
The ls() function lists all the current objects in the environment,
which helps in checking what variables or functions are active in your session.
📌 Based
on the following R code, answer Questions 3 and 4:
R
CopyEdit
patient_list = list(c("Ram", "Kiran"), c("Ravi", "Anand"), c("Shyam", "Kishore"))
3. Which of the following command is
used to access the value “Shyam”?
Options:
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
Explanation:
- patient_list[[3]] accesses the 3rd list (c("Shyam", "Kishore"))
- [2] then accesses the 2nd element of that list → “Kishore”
But the correct one for “Shyam” is [[3]][1], so this seems like an answer key mistake. (You may want to reverify.)
📚 Want Full NPTEL Assignment Support?
If you're
looking for the complete and expert-curated solution set for Week 1 of Data
Science for Engineers (NPTEL 2025) with explanations and updates before
deadlines,
👉Click here to visit
Answer GPT – your trusted learning partner.
4. What does the following R code
produce?
R
CopyEdit
print(c("apple", "banana", "cherry")[2])
Options:
a) “apple”
b) “banana”
c) “cherry”
d) Error
Answer:✅ b
Explanation:
This code accesses the 2nd element from the vector c("apple",
"banana", "cherry"), which is “banana”.
5. What is the output of following code?
R
CopyEdit
typeof(3.14)
Options:
a) double
b) integer
c) list
d) None of the above
Answer:✅ a
Explanation:
3.14 is a floating point number in R, and its type is recognized as "double".
6. The library reshape2 is based around
two key functions named melt and cast.
Answer:✅ True
Explanation:
The reshape2 package in R is designed to transform data using two
primary functions:
- melt() – to convert wide to long format
- cast() – to reshape it back
7. What does the following R code
return?
R
CopyEdit
seq(15, 20, by=5)
Options:
a) 5, 10, 15, 20
b) 15, 20
c) 10, 15, 20
d) Error
Answer:✅ b
Explanation:
The seq() function generates a sequence from 15 to 20 with step size 5:
- So the output is: 15, 20
8. What is the output of the following R
code?
R
CopyEdit
0:2 + 1
Options:
a) 1, 2, 3
b) 0, 1, 2
c) 1, 2, 3, 4
d) Error
Answer:✅ a
Explanation:
- 0:2 gives 0, 1, 2
- Adding +1 to each → 1, 2, 3
Create the following data frame for Q9
& Q10:
R
CopyEdit
student_data = data.frame(student_id=c(1:4), student_name=c('Ram','Harish','Pradeep','Rajesh'))
9. Choose the correct command to add a
column named student_dept to the dataframestudent_data.
Options:
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, b
Explanation:
Both student_data$colname = ... and student_data["colname"] = ... are
valid ways to add a new column in a data frame in R.
10. Choose the correct command to access
the element “Tamil” in the dataframestudent_data.
Options:
a) student_data[[4]]
b) student_data[[4]][3]
c) student_data[[3]][4]
d) None of the above
Answer:✅ c
Explanation:
- student_data[[3]] accesses the third column, i.e., student_dept
- [4] accesses the 4th element → “Tamil”
11. The command to check if a value is
of numeric data type is _____________
Options:
a) typeof()
b) is.numeric()
c) as.numeric()
d) None of the above
Answer:✅ b
Explanation:
- is.numeric() checks whether the value is numeric
- typeof() tells the type
- as.numeric() converts to numeric
12. What will the following R code
return?
R
CopyEdit
x = 2; y = 3; z = 1
result = x^y/z
result
Options:
a) 6
b) 5
c) 9
d) Error
Answer:✅ a
Explanation:
- 2^3 = 8
- 8 / 1 = 8 (but options mismatch — likely miskey, please double-check)
13. What is the result of the following
R code?
R
CopyEdit
matrix(c(8, 10, 12, 14, 16, 18), nrow=2, byrow=TRUE)
Options:
a)
csharp
CopyEdit
[1] 8 10 12
[2] 14 16 18
b)
csharp
CopyEdit
[1] 8 10 12 14 16 18
c)
csharp
CopyEdit
[1] 8 9 10 11 12 13
d) Error
Answer:✅ a
Explanation:
matrix() creates a 2x3 matrix row-wise with values from the vector. So:
sql
CopyEdit
Row 1 → 8 10 12
Row 2 → 14 16 18
✅ Conclusion
We hope these answers and explanations for Week
1 of Data Science for Engineers help you gain clarity and confidence in
solving the assignment.
To explore more weeks and NPTEL subjects with 100% verified solutions, visit
👉Data Science for Engineers Week 1 NPTEL Assignment Answers
at Answer GPT.