Python math module Python math module python python

Python math module


pow is built into the language(not part of the math library). The problem is that you haven't imported math.

Try this:

import mathmath.sqrt(4)


You can also import as

from math import *

Then you can use any mathematical function without prefixing math. e.g.

sqrt(4)


add:

import math

at beginning. and then use:

math.sqrt(num)  # or any other function you deem neccessary