#pyhton programing topic: Introduction to Method and Designing class Method overloading & Constructor overloading   ------------------   Question 1  Suppose your little sibling wants your help to check his math homework. He is done with  his homework but wants you to see if all his results are correct. Since the student with  all correct results gets 3 stars. However, you want your brother to check this on his own.  So, you design a calculator for him in python. You could have given your scientific  calculator but you wanted to give him a basic calculator and also wanted to see if you  can even design one.  Subtasks:  Create a class called Calculator.  Your class shall have 1 constructor and 4 methods, namely add, subtract,  multiply and divide.  Now, create an object of your class. After creating an object, it should print “Let’s  Calculate!”  Then take 3 inputs from the user: first value, operator, second value 5. Now based on the given operator, call the required method and print the result.  Sample Input:  1  +  2  Sample Output:  Let’s Calculate!  Value 1: 1  Operator: +  Value 2: 2  Result: 3

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

#pyhton programing

topic: Introduction to Method and Designing class

Method overloading & Constructor overloading

 

------------------

 

Question 1 

Suppose your little sibling wants your help to check his math homework. He is done with  his homework but wants you to see if all his results are correct. Since the student with  all correct results gets 3 stars. However, you want your brother to check this on his own.  So, you design a calculator for him in python. You could have given your scientific  calculator but you wanted to give him a basic calculator and also wanted to see if you  can even design one. 

Subtasks: 

  1. Create a class called Calculator. 
  2. Your class shall have 1 constructor and 4 methods, namely add, subtract,  multiply and divide. 
  3. Now, create an object of your class. After creating an object, it should print “Let’s  Calculate!” 
  4. Then take 3 inputs from the user: first value, operator, second value 5. Now based on the given operator, call the required method and print the result. 

Sample Input: 

Sample Output: 

Let’s Calculate! 

Value 1: 1 

Operator: + 

Value 2: 2 

Result: 3

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY