Question: Using python Problem Statement: In this lab, you will design a very simple complex number class. A complex number is a number that can be
Problem Statement: In this lab, you will design a very simple complex number class. A complex number is a number that can be expressed in the following form: @tb, where a and b are real numbers, and i is called an imaginary number Lab Scenario: You would ask two user input a and b using your favorite input function. According to the definition a and b are real numbers. You do not need to manipulate i since it's an imaginary part and there is no real solution for this part. The program will take the input, instantiate ComplexNumebr object and then print it to the standard output. For example: if user input a 5 and b 6 then the program should print 5+i6. If you remember: 1. For object instantiation, you need to use python built-in constructor_ init 2. For the print representation of an object the built-in function would be strYour class should define these two built-ins. The first parameter of all the class methods should be 'self followed by any other parameter you want to pass. 3. Lab Procedure 1. Prior starting of the work consider what is the information you need: what the output and what the input would be 2. Determine the steps to translate the code into the python class syntax 3. Test the application by giving some user input. Sample input/output: nter a: Enter b: 20 The complex number is: 10 i20
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
