Question: We have the class Complex and a function to multiply two complex numbers as follows. class Complex: def-init-(self, r, i ): self.real = r self.imag-

 We have the class Complex and a function to multiply twocomplex numbers as follows. class Complex: def-init-(self, r, i ): self.real =

We have the class Complex and a function to multiply two complex numbers as follows. class Complex: def-init-(self, r, i ): self.real = r self.imag- i def multiply(c1, c2) c = Complex(0, 0) c.real = c1.reare2.real-c1.imag"c2.imag c.imag- c1.real*c2.imag + c1.imag c2.real return c We want the function power(c, n) to compute c to the power n, where the type of c is Complex, and n is a positive integer def power(c, n if n=1 : # Base case return blank1 else: n1= n // 2 cl- blank2 # Compute c to the power nl to store in c1 if n1=n2: c2-c1 else: c2- self._multiply(c1, c) return blank3 # return c to the power n To complete,--blank!--should be , blank2 shoulod be , and blank3 Fill-in the three blanks. -No space is allowed to enter due to automated grading. -The two functions do not belong to the class Complex. - Shortest possible expressions required

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!