programming Python MOC


Numbers are useful for math, data, tracking, and more.

Operations

  • +: Addition
  • -: Subtraction
  • *: Multiplication
  • /: Normal division
  • **: Exponent
  • //: Divide without remainder
  • %: Division remainder

Types

Integers

Integers are whole numbers. Basic math operations work with them + - * /.

Floats

Floats are numbers with decimal places. The result of an operation with a float is a float, even if the float is a whole number: 4.6 + 2.4 = 7.0

Floating point math is used by computer languages for floats and is efficient, but results can change slightly: 0.2 + 0.1 = 0.30000000000000004.

Numbers can be rounded with round(number, decimal_places): round(42.31456, 2) -> 42.31.