0 out of 464 challenges solved
Write a Python function `convert_to_polar` that takes a complex number as input and returns its polar coordinates as a tuple `(r, theta)`. The polar coordinates consist of the magnitude `r` and the angle `theta` in radians. #### Example Usage ```python [main.nopy] convert_to_polar(1 + 1j) # Output: (1.4142135623730951, 0.7853981633974483) convert_to_polar(-1 - 1j) # Output: (1.4142135623730951, -2.356194490192345) convert_to_polar(0 + 0j) # Output: (0.0, 0.0) ``` #### Requirements - Use the `cmath` module to perform the conversion. - Ensure the function handles edge cases, such as when the input is `0 + 0j`. Good luck!
import cmath def convert_to_polar(complex_number): """ Convert a complex number to its polar coordinates. Args: complex_number (complex): The complex number to convert. Returns: tuple: A tuple containing the magnitude and angle in radians. """ # Use cmath.polar to compute the polar coordinates pass # Replace this with the actual implementation