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

Try this:

import math
math.sqrt(4)
Answer from dave on Stack Overflow
🌐
Python
docs.python.org › 3 › library › math.html
math — Mathematical functions
>>> from math import exp, expm1 >>> exp(1e-5) - 1 # gives result accurate to 11 places 1.0000050000069649e-05 >>> expm1(1e-5) # result accurate to full precision 1.0000050000166668e-05
🌐
W3Schools
w3schools.com › python › python_math.asp
Python Math
Python has also a built-in module called math, which extends the list of mathematical functions. ... When you have imported the math module, you can start using methods and constants of the module.
Discussions

Is "from math import *" and "import math" equivalent?
Nope: import math print(math.sqrt(4)) Vs from math import * print(sqrt(4)) The first is generally recommended, as it's more explicit about where things are coming from. More on reddit.com
🌐 r/learnpython
53
160
January 21, 2023
Python math module - Stack Overflow
See python library, and the list of built-ins. President James K. Polk – President James K. Polk · 2012-01-09 02:22:23 +00:00 Commented Jan 9, 2012 at 2:22 · I'm trying to imagine a scenario where you wouldn't want math to be imported automatically on startup. More on stackoverflow.com
🌐 stackoverflow.com
How to use import math in python
Sololearn is the world's largest community of people learning to code. With over 25 programming courses, choose from thousands of topics to learn how to code, brush up your programming knowledge, upskill your technical ability, or stay informed about the latest trends. More on sololearn.com
🌐 sololearn.com
11
2
June 5, 2021
[Python] The difference between "import math" and "from math import *"

The first method imports using the math namespace. You would use the sqrt function like this: math.sqrt(x)
The second method imports all the methods from math into the current namespace. You would use the sqrt function like this: sqrt(x)
Usually you want to use the first method, so you can avoid errors caused by functions having the same name.

More on reddit.com
🌐 r/learnprogramming
3
1
April 20, 2016
🌐
CodeHS
codehs.com › tutorial › 13325
Tutorial: Math Module in Python | CodeHS
Python Tutorial · python · By Zach Galant · High School · javascript · By Ryan Hart · High School · All Products · Coding LMS · CodeHS Pro · Computer Science Curriculum · Certifications · Professional Development · AI Creator · Typing · Cyber Range ·
🌐
YouTube
youtube.com › telusko
#16 Python Tutorial for Beginners | Import Math Functions in Python - YouTube
Python Tutorial to learn Python programming with examples Complete Python Tutorial for Beginners Playlist : https://www.youtube.com/watch?v=hEgO047GxaQ&t=0s&
Published: July 8, 2018
Views: 475K
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-math-module
Python Math Module - GeeksforGeeks
May 16, 2026 - To work with mathematical constants and functions in Python, you need to import the math module:
Find elsewhere
🌐
Mimo
mimo.org › glossary › python › math-module
Python math Module: sqrt, pow, log and pi
Yes, the math module is part of Python's standard library, so it does not require installation. It is included with Python distributions and can be used immediately after import.
🌐
Stanford CS
cs.stanford.edu › people › nick › py › python-math.html
Python Math
However, it means that code should not use == with float values, since the comparison will be thrown off by the error term. To compare 2 float values, the function math.isclose(a, b) will return True if they are very nearly same, allowing for a little error term difference. >>> import math >>> a = 5 * 3.14 >>> b = 6 * 3.14 - 3.14 >>> >>> a == b # == not reliable, yikes!
🌐
Real Python
realpython.com › ref › stdlib › math
math | Python Standard Library – Real Python
The Python math module provides a collection of common mathematical functions and constants, including those defined by the C standard. It includes functions for trigonometry, logarithms, powers, and other mathematical calculations.
🌐
Facebook
facebook.com › groups › pypcom › posts › 2376692882667767
Which is the correct way to import the math module ...
Popular groups · Find communities for you · Over 1 billion people across the globe are using Facebook Groups to explore their favorite topics · Log in · Categories · Science & tech · Travel · Animals · Sports & fitness · Entertainment
🌐
CodeChef
codechef.com › python-online-compiler
Online Python Compiler and Visualizer
Welcome to our AI-powered online Python compiler and interpreter, the perfect platform to run and test your Python code efficiently. Our tool makes coding easy for developers of any skill level, whether you're a beginner or experienced.
🌐
Docs by LangChain
docs.langchain.com › core components › tools
Tools - Docs by LangChain
1 day ago - Use this for any math problems.") def calc(expression: str) -> str: """Evaluate mathematical expressions.""" return str(eval(expression)) Define complex inputs with Pydantic models or JSON schemas: ... from pydantic import BaseModel, Field from typing import Literal class WeatherInput(BaseModel): """Input for weather queries.""" location: str = Field(description="City name or coordinates") units: Literal["celsius", "fahrenheit"] = Field( default="celsius", description="Temperature unit preference" ) include_forecast: bool = Field( default=False, description="Include 5-day forecast" ) @tool(arg
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-modules
Python Modules - GeeksforGeeks
3. Import With Alias: You can shorten a module's name using as. ... Explanation: math is accessed through the shorter alias m. Python provides several kinds of modules.
Published: September 19, 2026
🌐
Simmanchith
simmanchith.com › tutorial › python › python-math.aspx
Python Math - simmanchith
Python features a number of built-in math functions, including a large math module, which enables mathematical tasks to be carried out on numbers.
🌐
Python
peps.python.org › pep-0008
PEP 8 – Style Guide for Python Code | peps.python.org
Being explicit is important in this case. Be consistent in return statements. Either all return statements in a function should return an expression, or none of them should. If any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function (if reachable): # Correct: def foo(x): if x >= 0: return math.sqrt(x) else: return None def bar(x): if x < 0: return None return math.sqrt(x)
🌐
STEMpedia
ai.thestempedia.com › home › pictoblox extensions › python math module
Tutorial on Python Math Module: Definition, Usecase & Examples
June 27, 2023 - The math module defines a wide range of useful mathematical functions that can be used directly in any Python program. The use case for Math Module ranges from basic arithmetic operations (such as addition, subtraction, division, etc.), to more complex operations (such as trigonometric functions, complex numbers, etc.).Examples with Output · Below is an example of using the math module to calculate the absolute value of a number. import math # initializing the number number = -2.45 # calculating absolute value of number absolute_value = math.fabs(number) # printing the absolute value print("Absolute value of",number,"is",absolute_value)
🌐
W3Schools
w3schools.com › python › gloss_python_arithmetic_operators.asp
Python Arithmetic Operators
math.acos() math.acosh() math.asin() math.asinh() math.atan() math.atan2() math.atanh() math.ceil() math.comb() math.copysign() math.cos() math.cosh() math.degrees() math.dist() math.erf() math.erfc() math.exp() math.expm1() math.fabs() math.factorial() math.floor() math.fmod() math.frexp() math.fsum() math.gamma() math.gcd() math.hypot() math.isclose() math.isfinite() math.isinf() math.isnan() math.isqrt() math.ldexp() math.lgamma() math.log() math.log10() math.log1p() math.log2() math.perm() math.pow() math.prod() math.radians() math.remainder() math.sin() math.sinh() math.sqrt() math.tan()