Not exactly. ‘From math important *’ Says “bring the box of math tools and dump it out on the table with the rest of my tools.” Calls look like: ‘Thing_from_math()’ Whereas ‘import math’ says “bring me the box of math tools and I’ll grab the tools as I need them”. Calls should look like: ‘Math.thing_from_math()’ And finally: ‘From math import thing_from_math’ Says “bring me the box of math tools and only unpack the specific tools I asked for. Calls look like: ‘thing_from_math()’ Answer from Deleted User on reddit.com
🌐
Python
docs.python.org › 3 › library › math.html
math — Mathematical functions
2 weeks ago - >>> 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

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
python - What is the difference between import numpy and import math - Stack Overflow
I started exploring python and was trying to do some calculation with pi. Here's how I got it: import math as m m.pi But someone suggested using numpy instead of math: import numpy as np np.pi Wh... More on stackoverflow.com
🌐 stackoverflow.com
Python: How to integrate a math function using only math module? - Stack Overflow
Just started learning python, and was asked to define a python function that integrate a math function. We were instructed that the python function must be in the following form: (for example, to calculate the area of y = 2x + 3 between x=1 and x=2 ) ... and we are not allowed to use/import any ... More on stackoverflow.com
🌐 stackoverflow.com
Python cannot import anything from math in new files...

The python math module does not include a 'mean' function, you'll need to import it from elsewhere or make one yourself.

https://docs.python.org/3/library/math.html

More on reddit.com
🌐 r/learnpython
6
1
October 13, 2016
🌐
CodeHS
codehs.com › tutorial › ryan › math-module-in-python
Tutorial: Math Module in Python | CodeHS
Python Tutorial · python · By Zach Galant · High School · javascript · By Ryan Hart · High School · Coding LMS · Online IDE · CodeHS Pro · Computer Science Curriculum · Certifications · Professional Development · AI Creator · Typing · Cyber Range ·
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-math-module
Python Math Module - GeeksforGeeks
July 26, 2025 - Math module provides built-in functions to find such values and even to change the values between degrees and radians. sin(), cos() and tan() functions returns the sine, cosine and tangent of value passed as the argument. The value passed in this function should be in radians. Example: This prints the trigonometric values of π/6. ... import math a = math.pi/6 print ("The value of sine of pi/6 is : ", end="") print (math.sin(a)) print ("The value of cosine of pi/6 is : ", end="") print (math.cos(a)) print ("The value of tangent of pi/6 is : ", end="") print (math.tan(a))
Find elsewhere
🌐
Mimo
mimo.org › glossary › python › math-module
Python Math Module: Syntax, Usage, and Examples
The math module in Python is built-in, meaning you don’t need to install it separately. To access its functions, import it using:
🌐
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
🌐
OpenStax
openstax.org › books › introduction-python-programming › pages › 2-6-the-math-module
2.6 The math module - Introduction to Python Programming | OpenStax
March 13, 2024 - This module defines functions such as sqrt() (square root). To call sqrt(), a program must import math and use the resulting math variable followed by a dot.
🌐
Geo-python
geo-python.github.io › site › develop › notebooks › L4 › modules.html
Loading and using modules — Geo-Python site documentation
August 17, 2020 - Here we have loaded the math module by typing import math, which tells Python to read in the functions in the math module and make them available for use.
🌐
Dummies
dummies.com › article › technology › programming-web-design › python › how-to-import-python-modules-264467
How to Import Python Modules | dummies
June 27, 2025 - To do that, you just follow the import command with the name of the Python module you want to import. For example, this imports the entire math module, which has lots of functions and stuff for doing math:
🌐
Stanford CS
cs.stanford.edu › people › nick › py › python-math.html
Python Math
This was thought to be the least confusing approach for the many Python users who do not want to introduce complex numbers. For those wanting functions with complex number support, use the cmath module and its included sqrt(), sin(), etc. functions instead of the regular math functions (cmath docs). >>> import cmath >>> cmath.sqrt(-1) 1j >>> cmath.sin(1j) 1.1752011936438014j
🌐
LabEx
labex.io › tutorials › python-how-to-import-math-functions-safely-446106
How to import math functions safely | LabEx
Learn essential Python techniques for importing and using math functions with error handling and best practices for safe and efficient mathematical operations.
🌐
Quora
quora.com › How-do-I-import-a-math-library-in-Python
How to import a math library in Python - Quora
Answer (1 of 7): It depends which math library - if you mean the standard library [1] : [code]import math [/code]If you mean some other library (maybe scipy, or sympy, or numpy) then you need to install them first (using pip install …) and then import them as you need to based on the documentat...
🌐
Python
docs.python.org › 3 › library › statistics.html
statistics — Mathematical statistics functions
Source code: Lib/statistics.py This module provides functions for calculating mathematical statistics of numeric ( Real-valued) data. The module is not intended to be a competitor to third-party li...
🌐
Real Python
realpython.com › ref › stdlib › math
math | Python Standard Library – Real Python
The Python math module provides a comprehensive collection of mathematical functions and constants, making it a go-to tool for performing mathematical operations in Python. It includes functions for trigonometry, logarithms, powers, and other common mathematical calculations. ... Imagine you’re working on a physics simulation and need to calculate the trajectory of a projectile. The math module can help compute the necessary trigonometric values to determine its path: ... >>> import math >>> velocity = 20 # m/s >>> angle = 45 # degrees >>> angle_rad = math.radians(angle) >>> horizontal_velocity = velocity * math.cos(angle_rad) >>> vertical_velocity = velocity * math.sin(angle_rad) >>> horizontal_velocity 14.142135623730951 >>> vertical_velocity 14.14213562373095
Top answer
1 of 2
4

Let's say your integration function looks like this:

def integrate(func, lo_x, hi_x):
    #... Stuff to perform the integral, which will need to evaluate
    # the passed function for various values of x, like this
    y = func(x)
    #... more stuff
    return value

Then you can call it like this:

value = integrate(lambda x: 2 * x + 3, 1, 2)

edit

However, if the call to the integration function has to look exactly like

integrate( 2 * x + 3, 1, 2 )

then things are a bit trickier. If you know that the function is only going to be called with a polynomial function you could do it by making x an instance of a polynomial class, as suggested by M. Arthur Vaïsse in his answer.

Or, if the integrate( 2 * x + 3, 1, 2 ) comes from a string, eg from a command line argument or a raw_input() call, then you could extract the 2 * x + 3 (or whatever) from the string using standard Python string methods and then build a lambda function from that using exec.

2 of 2
2

Here come an implementation that fill the needs I think. It allow you to define mathematical function such as 2x+3 and propose an implementation of integral calculation by step as described here [http://en.wikipedia.org/wiki/Darboux_integral]

import math

class PolynomialEquation():
    """ Allow to create function that are polynomial """
    def __init__(self,coef):
        """ 
        coef : coeficients of the polynome.

        An equation initialized with [1,2,3] as parameters is equivalent to:
            y = 1 + 2X + 3X²

        """
        self.coef = coef

    def __call__(self, x):
        """
        Make the object callable like a function.
        Return the value of the equation for x
        """
        return sum( [self.coef[i]*(x**i) for i in range(len(self.coef)) ])

def step_integration(function, start, end, steps=100):
    """ 
    Proceed to a step integration of the function.
    The more steps there are, the more the approximation is good.
    """
    step_size = (end-start)/steps
    values = [start + i*step_size for i in range(1,steps+1)]
    return sum([math.fabs(function(value)*step_size) for value in values])


if __name__ == "__main__":
    #check that PolynomialEquation.value works properly. Assert make the program crash if the test is False.

    #y = 2x+3 -> y = 3+2x -> PolynomialEquation([3,2])
    eq = PolynomialEquation([3,2])
    assert eq(0) == 3
    assert eq(1) == 5
    assert eq(2) == 7

    #y = 1 + 2X + 3X² -> PolynomialEquation([1,2,3])
    eq2 = PolynomialEquation([1,2,3])
    assert eq2(0) == 1
    assert eq2(1) == 6
    assert eq2(2) == 17

    print(step_integration(eq, 0, 10))
    print(step_integration(math.sin, 0, 10))

EDIT : in truth the implementation is only the upper Darboux integral. The true Darboux integral could be computed if really needed by computing the lower Darboux integral ( replace range(1, steps+1) by range(steps) in step_integration function give you the lower Darboux function. And then increase the step parameter while the difference between the two Darboux function is greater than a small value depending on your precision need (could be 0.001 for example). Thus a 100 step integration is suppose to give you a decent approximation of the integral value.