Question

Python!!!! Write the class Calculator including: a function called addthat takes two numbers and returns their...

Python!!!!

Write the class Calculator including:

  • a function called addthat takes two numbers and returns their sum
  • a function called subtractthat takes two numbers and returns their difference (subtract the second from the first)
  • a function called multiply that takes two numbers and returns their product
  • a function called divide that takes two numbers and returns the value of the first divided by the second. If the second number is a zero, do not divide, and return "You can't divide by zero!"
0 0
Add a comment Improve this question Transcribed image text
Answer #1

class Calculator:
def addthat(num1,num2):
return num1+num2
def subtractthat(num1,num2):
return num1-num2
def multiply(num1,num2):
return num1*num2
def divide(num1,num2):
if(num2==0):
return "You can't divide by zero!"
else:
return num1//num2
  
  
num1=int(input("Enter num1: "))
num2=int(input("Enter num1: "))
print("Addition: ",Calculator.addthat(num1,num2))
print("Substraction: ",Calculator.subtractthat(num1,num2))
print("Multiplication",Calculator.multiply(num1,num2))
print("Division: ",Calculator.divide(num1,num2))

Add a comment
Know the answer?
Add Answer to:
Python!!!! Write the class Calculator including: a function called addthat takes two numbers and returns their...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT