Calculator

Imagine you are developing a software package for a tech company. This package needs to include a calculator for their various computational needs. However, they have special requirements. They want to be able to perform not only basic arithmetic operations like addition, subtraction, multiplication, and division, but also need scientific calculations like sine, cosine, and tangent for their advanced engineering needs.
Your task is to implement a Calculator class with methods for addition, subtraction, multiplication, and division. These methods should handle the operations when the instances of the Calculator class are involved in mathematical expressions. For this challenge, the specific methods that should be used are add for addition, sub for subtraction, mul for multiplication, and div for division.
Next, you are required to implement a ScientificCalculator class, inheriting from the Calculator class, that adds methods for the sine, cosine, and tangent functions. The functions sin, cos, and tan should use radian units and you may use the math package of Python for these computations
Input
Output
print(Calculator().add(2, 3))
5
print(ScientificCalculator().sin(30))
-0.9880316240928618
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue