from scipy.integrate import quad
quad(lambda x: x**2, 0, 1)[0]
0.33333333333333337
Recall: A lambda function is a small anonymous function, which can only have one expression as a return value.
def sq(x): # define a named function
return x**2
sq(4) # call the function
16
lambda x: x**2 # define an anonymous function
<function __main__.<lambda>(x)>
_(4) # call it
16
(lambda x: x**2)(4) # define and call an anonymous function
16
from sympy import *
x = Symbol('x')
integrate(x**2, x)
integrate(x**2, (x, 0, 1))