WorksheetsDATA SCIENCE 4
Total questions: 20
Worksheet time: 12mins
What will be the output of the following R code?
x <- c(1, 2, 3)
y <- c("4", "5", "six")
z <- c(x, y)
z[4:6]
class(z)
[1] "4" "5" "six"
[1] "character"
[1] 4 5 six
[1] "numeric"
[1] 4 5 six
[1] "mixed"
[1] "1" "2" "3"
[1] "character"
What will be the output of this code?
x <- c(TRUE, FALSE, TRUE)
y <- c(1, 0, 2)
sum(x * y)
A. 3
B. 2
C. 1
D. Error
x <- c(1, 2, 3)
y <- c(4, 5, 6)
x + y
A. 5 7 9
B. Error
C. x4 x5 x6
D. 1 2 3 4 5 6
What does the c() function do in R?
A. Cuts a string
B. Creates a matrix
C. Combines values into a vector
D. Converts data to character type
What will this code return?
x <- c(10, 20, 30, 40) x[2:3]
A. 10 20
B. 20 30
C. 30 40
D. 20 30 40
Which function is used to create a data frame?
A. create.frame()
B. frame()
C. data.frame()
D. make.frame()
What will length(c(2, 4, 6, 8)) return?
A. 2
B. 4
C. 8
D. Error
What will be the output?
x <- c(TRUE, FALSE, TRUE)
sum(x)
A. 3
B. 1
C. 2
D. Error
Which of the following is NOT a basic data type in R?
A. Numeric
B. Character
C. Matrix
D. Logical
What will be the output of the following?
class(3.14)
A. "double"
B. "numeric"
C. "integer"
D. "float"
The function used to create a vector in R is (a) .
In R, indexing starts from the number (a) .
The number 4+2i is of (a) data type in R.
The data type used to store TRUE or FALSE values is called (a) .
Which of these is a logical constant in R?
A. yes / no
B. true / false
C. TRUE / FALSE
D. 1 / 0
Which of the following best describes "datafication"?
A. Collecting structured data from large systems
B. Turning many aspects of life into quantified data
C. Cleaning and preprocessing datasets
D. Using graphs to visualize information
Overfitting in a model means—
A. The model performs well on both training and test data
B. The model is too simple and misses key patterns
C. The model fits the training data too well but fails to generalize
D. The model has low variance and high bias
What is the role of a sample in statistical inference?
A. It is the entire dataset we want to analyze
B. It is the variable of interest
C. It is a subset used to make inferences about the population
D. It contains only outliers
In R, the data type used to represent categorical variables is called a ______.
FACTOR
LIST
DATA
DATA FRAME
What is the output?
x <- c(5L, 10L, 15L)
typeof(x)
A. "integer"
B. "numeric"
C. "double"
D. "character"
