Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Advanced Math

# Modulo operation, aka remainder
print(7 % 3)   # => 1
# i % j have the same sign as j, unlike C
print(-7 % 3)  # => 2

# Exponentiation (x**y, x to the yth power)
print(2**3)  # => 8

# Enforce precedence with parentheses
print(1 + 3 * 2)    # => 7
print((1 + 3) * 2)  # => 8

Contributors: