0
0
R Programmingprogramming~10 mins

Complex type in R Programming - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a complex number with real part 3 and imaginary part 4.

R Programming
z <- complex(real = [1], imaginary = 4)
Drag options to blanks, or click blank then click option'
A4
B3
C5
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the imaginary part in the real argument.
Using 0 instead of 3 for the real part.
2fill in blank
medium

Complete the code to get the imaginary part of the complex number z.

R Programming
imag_part <- [1](z)
Drag options to blanks, or click blank then click option'
AMod
BRe
CArg
DIm
Attempts:
3 left
💡 Hint
Common Mistakes
Using Re() which returns the real part.
Using Mod() which returns the magnitude.
3fill in blank
hard

Fix the error in the code to create a complex number with real part 2 and imaginary part 5.

R Programming
z <- complex([1] = 2, imaginary = 5)
Drag options to blanks, or click blank then click option'
Aimaginary
Bimag
Creal
Dim
Attempts:
3 left
💡 Hint
Common Mistakes
Using imaginary for the real part.
Using incorrect argument names like im or imag.
4fill in blank
hard

Fill both blanks to create a vector of complex numbers with real parts 1 to 3 and imaginary parts 4 to 6.

R Programming
z_vec <- complex(real = [1], imaginary = [2])
Drag options to blanks, or click blank then click option'
A1:3
B4:6
Cc(1,2,3)
Dc(4,5,6)
Attempts:
3 left
💡 Hint
Common Mistakes
Using mismatched lengths for real and imaginary parts.
Using vectors with wrong values.
5fill in blank
hard

Fill all three blanks to create a named list of complex numbers where keys are uppercase letters and values are complex numbers with real parts 1 to 3 and imaginary parts 3 to 5.

R Programming
names <- toupper(letters[1:3])
values <- complex(real = [1], imaginary = [2])
complex_list <- setNames([3], names)
Drag options to blanks, or click blank then click option'
A1:3
B3:5
Cvalues
Dc(1,2,3)
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong sequences for real or imaginary parts.
Putting the wrong variable inside the list.