Subtraction

Download python eBook

Example

a, b = 1, 2

# Using the "-" operator:
b - a                  # = 1


import operator        # contains 2 argument arithmetic functions
operator.sub(b, a)     # = 1

Possible combinations (builtin types):

  • int and int (gives an int)
  • int and float (gives a float)
  • int and complex (gives a complex)
  • float and float (gives a float)
  • float and complex (gives a complex)
  • complex and complex (gives a complex)

Stats

Contributors: 4
2016-07-23
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook