# Run this cell using Ctrl+Enter (⌘+Enter on Mac).
from testing import exercise
from typing import Tuple

import math

Complex = Tuple[float, float]
Polar = Tuple[float, float]

@exercise
def imaginary_power(n : int) -> int:
    # If n is divisible by 4
    if n % 4 == 0:
        return ...
    else:
        return ...

@exercise
def complex_add(x : Complex, y : Complex) -> Complex:
    # You can extract elements from a tuple like this
    a = x[0]
    b = x[1]
    
    c = y[0]
    d = y[1]
    
    # This creates a new variable and stores the real component into it
    real = a + c
    # Replace the ... with code to calculate the imaginary component
    imaginary = ...
    
    # You can create a tuple like this
    ans = (real, imaginary)
    
    return ans

@exercise
def complex_mult(x : Complex, y : Complex) -> Complex:
    # Fill in your own code
    return ...

@exercise
def conjugate(x : Complex) -> Complex:
    return ...

@exercise
def complex_div(x : Complex, y : Complex) -> Complex:
    return ...

@exercise
def modulus(x : Complex) -> float:
    return ...

@exercise
def complex_exp(x : Complex) -> Complex:
    return ...

@exercise
def complex_exp_real(r : float, x : Complex) -> Complex:
    return ...

@exercise
def polar_convert(x : Complex) -> Polar:
    r = ...
    theta = ...
    
    return (r, theta)

@exercise
def cartesian_convert(x : Polar) -> Complex:
    return ...

@exercise
def polar_mult(x : Polar, y : Polar) -> Polar:
    return ...

@exercise
def complex_exp_arbitrary(x : Complex, y : Complex) -> Complex:
    return ...