Calculator

class calculator.Calculator[source]

Bases: object

The main Calculator class, which provides the arithmetic operations.

Methods Summary

add(a, b)

Functions adds two numbers

divide(a, b)

Functions divdes one number by another

multiply(a, b)

Functions multiplies two numbers

subtract(a, b)

Functions subtracts one number from another

Methods Documentation

add(a, b)[source]
Functions adds two numbers

c = a + b

Parameters:
  • a (number) – First addend

  • b (number) – Second addend

Returns:

c – Sum of inputs

Return type:

number

divide(a, b)[source]
Functions divdes one number by another

c = a / b

Parameters:
  • a (number) – Dividend

  • b (number) – Divisor, must not be zero

Returns:

c – Ratio of inputs

Return type:

number

multiply(a, b)[source]
Functions multiplies two numbers

c = a * b

Parameters:
  • a (number) – First factor

  • b (number) – Second factor

Returns:

c – Product of inputs

Return type:

number

subtract(a, b)[source]
Functions subtracts one number from another

c = a - b

Parameters:
  • a (number) – Minuend

  • b (number) – Subtrahend

Returns:

c – Difference of inputs

Return type:

number