Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add two numbers and print the result.
R Programming
result <- 5 [1] 3 print(result)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
✗ Incorrect
The plus operator + adds two numbers together.
2fill in blank
mediumComplete the code to multiply two numbers and print the result.
R Programming
result <- 4 [1] 7 print(result)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition or division instead of multiplication.
✗ Incorrect
The asterisk * operator multiplies two numbers.
3fill in blank
hardFix the error in the code to divide two numbers and print the result.
R Programming
result <- 10 [1] 2 print(result)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication or subtraction instead of division.
✗ Incorrect
The forward slash / operator divides the first number by the second.
4fill in blank
hardFill both blanks to create a named vector with names for the numbers 4 and 5.
R Programming
squares <- c([1] = 4, [2] = 5) print(squares)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using names that do not match the vector values.
✗ Incorrect
The names four and five label the vector elements for 4 and 5.
5fill in blank
hardFill all three blanks to create a vector of numbers, filter those greater than 3, and square them.
R Programming
numbers <- c([1], [2], [3]) squares <- numbers[numbers > 3]^2 print(squares)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using only numbers less than or equal to 3.
✗ Incorrect
The vector contains 2, 4, and 5. Only 4 and 5 are greater than 3 and get squared.