Recall & Review
beginner
What is operator precedence in R?
Operator precedence is the set of rules that determines the order in which different operators are evaluated in an expression.
Click to reveal answer
beginner
Which operator has higher precedence: multiplication (*) or addition (+)?
Multiplication (*) has higher precedence than addition (+), so it is evaluated first.
Click to reveal answer
beginner
How does parentheses affect operator precedence?
Parentheses change the order of evaluation by forcing the expression inside them to be evaluated first, regardless of normal precedence rules.
Click to reveal answer
intermediate
What is the precedence order between logical AND (&&) and logical OR (||) in R?
Logical AND (&&) has higher precedence than logical OR (||), so && is evaluated before ||.
Click to reveal answer
advanced
In the expression 3 + 4 * 2 / (1 - 5)^2^3, which operation is evaluated first?
The expression inside parentheses (1 - 5) is evaluated first, then exponentiation (^), then multiplication (*) and division (/), and finally addition (+).
Click to reveal answer
In R, which operator is evaluated first in the expression 5 + 3 * 2?
✗ Incorrect
Multiplication (*) has higher precedence than addition (+), so 3 * 2 is evaluated first.
What does parentheses do in an expression like (2 + 3) * 4?
✗ Incorrect
Parentheses force the expression inside to be evaluated first, so 2 + 3 is done before multiplication.
Which has higher precedence in R: logical AND (&&) or logical OR (||)?
✗ Incorrect
Logical AND (&&) has higher precedence than logical OR (||).
In the expression 2^3^2, which exponentiation is done first?
✗ Incorrect
Exponentiation in R is right-associative, so 3^2 is evaluated first.
What is the result of 4 + 6 / 3 in R?
✗ Incorrect
Division (/) has higher precedence, so 6 / 3 = 2, then 4 + 2 = 6.
Explain how operator precedence affects the evaluation of the expression 7 + 3 * 2 in R.
Think about which operation R does first without parentheses.
You got /3 concepts.
Describe how parentheses can change the result of an expression with mixed operators in R.
Consider how you can force R to do addition before multiplication.
You got /3 concepts.