Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Simplilearn

PG Data Science With R (April 2021)


Assignment 1

Please note:
If the code has error, Print “Error” as answer.
Else print the answer/output.
Questions can have more than one correct answer in MCQ

Q1.
x=8
print x
Answer output is: [1] "a" "b" "c"

Q2
x<-y<-6
print(x)
Answer output is:[1] 6
Q3
b=7
a<-6<-b
Answer: Error in 6 <- b : invalid (do_set) left-hand side to
assignmen
Q4
d=15
a<-c<-d
print (a)
Answer output is:[1] 15
Q5
x<-y< -5
print(x)
Answer output is[1] 5

Q6
Which of the below are invalid

var_name2 <- 5 # valid

var_name% <- 5 #invalid error

2var_name <- 5 #invalid error


.var_name <- 5 # valid
var.name <- 5 # valid

.2var_name<- 5 #invalid error


var_name <- 5 # valid
Q7.
var_i = 10
print(paste('Bulls and', var_i, 'bears'))
Answer output: "Bulls and 10 bears"

Q8
What is the output of the following statements?
15/4 #output: [1] 3.75

15%4 #output: Error: unexpected input in "15%4"

15%/%4 #output: [1] 3


15%%4 #output: [1] 3

15//4 #output: Error: unexpected '/' in "15//"

Q9
b=100
print(type(b) )
Answer output:#Error in type(b) : could not find function type

Q10
c<- 123
print((typeof(b)) # output: double

print(class(b)) # output: numeric


Q11
c=15L
print((typeof(c)) # invalid

print(class(c)) Error: unexpected symbol in Answer: c. Data


typeof(c) output is: integer

Q12.
Which of the following is incorrect?
s1='a'
s2="a"
s3='add'
s4="add"

Answer: All are valid

Q13.
What is the output
s5<-"Hello" #Error: unexpected symbol

s6="C" # invalid

is.string(s6) Anwer: Error in is.string(s6) : could not find function "


is.string"
is.character(s6) # TRUE

Q14
What is the output of
data()
Answer: : returns all the data set available in the R.

Q15
What is the output of
help("bar") Answer error should be: ?(bar)

apropos("bar") Answer:
#> apropos("bar")
[1] "barplot" "barplot.default" "
?bar TRUE bartlett.test" "getTxtProgressBar"
[5] "getWinProgressBar" "setStatusBar" "
setTxtProgressBar" "setWinProgressBar"
[9] "txtProgressBar" "winProgressBar"
Q16
Write a program that prints the sequence Answer:
n<-c(1:100)
for (n in nums){
3,6,9,12,15,18,21,24,27,33,36.... if ((n %% 3 == 0) &
(n%%10 != 0)) {
Multiples of 3 except ones ending with 0. print(n)
} else {
}
}
Q17
Which of the following is not an advantage of R

a. Strong statistical functionalities


b. Platform independence
c. Can embed Java code seamlessly in R code
d. Strong graphs and plots
Anser: C
Q18.
Which of the following is a good IDE for R

a. jIDE
b. RStudio
c. Jupyter Notebook
d. aRcade
Answer: b

Q19
Which of the following skills is not needed for a data
scientist?
a. Strong Unix admin skills
b. Sugar coating and exaggerating facts Anwer: b

c. Good communication and story telling


d. Statistics and Probability
Q20.
Which of the following takes most of the time of a data
scientist?
a. Machine Learning Model building
b. Machine Learning Model improvement
c. Data cleaning and data preprocessing
d. Analytics
Answer: c

You might also like