0
0
R Programmingprogramming~20 mins

Complex type in R Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Complex Type Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of complex number arithmetic
What is the output of this R code when adding two complex numbers?
R Programming
z1 <- 3 + 4i
z2 <- 1 - 2i
result <- z1 + z2
print(result)
A4+2i
B2+6i
C4-2i
D4+6i
Attempts:
2 left
💡 Hint
Remember to add real parts and imaginary parts separately.
Predict Output
intermediate
2:00remaining
Result of complex conjugate function
What does the following R code print?
R Programming
z <- 5 - 7i
conj_z <- Conj(z)
print(conj_z)
A5+7i
B5-7i
C-5+7i
D-5-7i
Attempts:
2 left
💡 Hint
The conjugate of a complex number flips the sign of the imaginary part.
Predict Output
advanced
2:30remaining
Output of complex division
What is the output of this R code dividing two complex numbers?
R Programming
z1 <- 2 + 3i
z2 <- 1 - 1i
result <- z1 / z2
print(round(result, 2))
A2.5-0.5i
B2.5+0.5i
C-0.5+2.5i
D0.5-2.5i
Attempts:
2 left
💡 Hint
Divide complex numbers by multiplying numerator and denominator by the conjugate of the denominator.
🧠 Conceptual
advanced
1:30remaining
Understanding complex number modulus
What does the R function Mod() return when applied to a complex number?
AThe angle (in radians) of the complex number
BThe real part of the complex number
CThe imaginary part of the complex number
DThe magnitude (distance from origin) of the complex number
Attempts:
2 left
💡 Hint
Think about how far the point is from zero on the complex plane.
🔧 Debug
expert
2:30remaining
Identify the error in complex number creation
Which option will cause an error when trying to create a complex number in R?
R Programming
z <- complex(real = 3, imaginary = 4)
Acomplex(real = 3, imaginary = 4)
Bcomplex(real = 3, imag = 4)
Ccomplex(real = 3, imaginary = 4i)
Dcomplex(real = 3, imaginary = "4")
Attempts:
2 left
💡 Hint
Check the exact argument names for the complex() function in R.