**Math (built-in)**

December 7, 2016

Basic Math in Python works as you expect it will:

+ adds

- subtracts

* multiplies

/ divides

x**y raises x to the exponent y

( ) work like they should

% modulo - gives remainder of division

Also works as expected

PEMDAS:

Parentheses

Exponents (or unary operators)

Multiplication and Division

Addition and Subtraction

Left to Right

3*(4+5) is not the same as (3*4)+5, as you’d expect.

Don’t forget that you have to use * to multiply

For instance, in math: 3(4+5) is fine… in programming, you need 3*(4+5)

Use math in any expression where a numeric is expected.

Please reload

Please reload