Question: Question 3 [ 1 0 points ] : Every class includes instance var ables to record its internal data. A complex number, for example, has

Question 3[10 points]: Every class includes instance varables to record its internal data. A complex number, for example, has a real and an imaginary component. This question will shorten these words to their first four letters: _real and _imag. Type the following code into a new file .py file and save it:
Based on the definition of the Complex class, write the Python statement that instantiates the Complex object -9+67i
Outside the class definition. Type the following statements and run your file:
What does Python display?
You might notice that the result you got is probably not very informative, and probably not the sort of information you would like. When using a print function, an instance should response to that function and print itself. For printing, it means we need to provide a method in Complex, which gets called when we print an instance.
Add the following method inside the Complexclass (def statement indentation must match the indentation of the method definition):Now we have a method that will display the results in a form recognizable to the user. Do not forget that the value returned by this method is a string, not a Complex object.
Save your file and run it again in an interactive session, trying one more time to display the following instance of the Complex class.For, this question, select the box that applies:S. checked my answer using the Python interpreter.
I completed it using an IDE first.
I did not verify my answer in any way, but I am confident in my answer.
I struggled to complete the question.
Now that we can create an object and display it, we will start with a very easy operation for complex numbers, compute the conjugate. A complex conjugate of a complex number is another complex number that has the same real part as the original complex number and the imaginary part has the same magnitude but opposite sign. For example, the complex conjugate of a+bi is equal to a-bi. Complete the implementation of the conjugate method in the Complex class. Note that this method must create a new instance of the Complex class, not create a string that looks like one!
 Question 3[10 points]: Every class includes instance varables to record its

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!