calculator module

class calculator.Calculator(name)[source]

Bases: object

A simple calculator class that performs basic arithmetic operations.

name

The name of the calculator.

Type:

str

add(num1, num2)[source]

Adds two numbers.

Parameters:
  • num1 (int or float) – The first number.

  • num2 (int or float) – The second number.

Returns:

The sum of the two numbers.

Return type:

int or float

divide(num1, num2)[source]

Divides two numbers.

Parameters:
  • num1 (int or float) – The dividend.

  • num2 (int or float) – The divisor.

Returns:

The quotient of the two numbers.

Return type:

int or float

multiply(num1, num2)[source]

Multiplies two numbers.

Parameters:
  • num1 (int or float) – The first number.

  • num2 (int or float) – The second number.

Returns:

The product of the two numbers.

Return type:

int or float

subtract(num1, num2)[source]

Subtracts two numbers.

Parameters:
  • num1 (int or float) – The first number.

  • num2 (int or float) – The second number.

Returns:

The difference between the two numbers.

Return type:

int or float