Error:

Check if the string is a valid number

def is_number(s):
    try:
        float(s)
        return True
    except ValueError:
        return False

Round float number

round(1.9) # 2.0

Generate random number in range

import random
dice = random.randint(1,6)

Convert decimal number to binary

# with 0b prefix
a = bin(10) # 0b1010
# without 0b prefix
strippedBin = lambda x: x >= 0 and bin(x)[2:] or "-" + bin(x)[3:]
a = strippedBin(10) # 1010

Convert decimal number to hex

# with 0x prefix
a = hex(10) # '0xa'
# without 0x prefix
strippedHex = lambda x: x >= 0 and hex(x)[2:] or "-" + hex(x)[3:]
a = strippedHex(10) # 'a'

Convert decimal number to oct

# with 0 prefix
a = oct(10) # '012'
# without 0 prefix
strippedOct = lambda x: x >= 0 and oct(x)[1:] or "-" + oct(x)[2:]
a = strippedOct(10) # '12'

Convert binary number to decimal

a = int('1010', 2) # 10

Convert hex number to decimal

a = int('aa', 16)

Convert oct number to decimal

a = int('120', 8) # 80

Euler constant

import math
math.e # 2.718281828459045

Pi constant

import math
math.pi # 3.141592653589793

Calculate natural logarithm

import math
math.log(math.e**3) # 3.0

Trigonometric functions

import math
math.sin(math.pi) # 1.2246467991473532e-16
math.cos(math.pi) # -1.0
math.tan(math.pi) # -1.2246467991473532e-16

Find maximum number

max(3, 99, 5) # 99

Find minimum number

min(3, 99, 5) # 3

Calculate absolute value of the number

abs(-1.5) # 1.5

Calculate exponent

import math
math.exp(2) # 7.38905609893065

Calculate power

2**10 # 1024