You will write a function for any power of , positive or negative, and a function that divides one complex number by another by the rule. The checker tests them against Python.
The idea. depends only on the remainder n % 4, which Python gives from to even for negative n. To divide by , multiply the top and the bottom by :
Your tasks.
power_of_i(n): return 1, 1j, -1 or -1j, chosen by n % 4.divide(a, b, c, d): return the pair of real and imaginary parts of the quotient.total to the sum of power_of_i(n) for n from to .Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…
With Standard, you also open 11 more problems, 2 Python labs and 1 extra course. Everything you have used here stays free, always.