0
0
SciPydata~10 mins

Why numerical integration computes areas in SciPy - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the numerical integration function from scipy.

SciPy
from scipy.integrate import [1]
Drag options to blanks, or click blank then click option'
Asolve
Bquad
Cintegrate
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'solve' which is not a scipy integration function.
Using 'sum' which is a Python built-in, not for integration.
2fill in blank
medium

Complete the code to define the function to integrate: f(x) = x squared.

SciPy
def f(x):
    return x[1]2
Drag options to blanks, or click blank then click option'
A*
B+
C//
D**
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' which multiplies but does not square.
Using '//' which is integer division.
3fill in blank
hard

Fix the error in the integration call to compute the area under f from 0 to 1.

SciPy
area, error = quad([1], 0, 1)
Drag options to blanks, or click blank then click option'
Af(x)
Bf()
Cf
Df(x=0)
Attempts:
3 left
💡 Hint
Common Mistakes
Calling the function inside quad instead of passing the function itself.
Passing an undefined variable like x.
4fill in blank
hard

Fill both blanks to create a dictionary of areas for functions f and g over 0 to 1.

SciPy
areas = { 'f': quad([1], 0, 1)[0], 'g': quad([2], 0, 1)[0] }
Drag options to blanks, or click blank then click option'
Af
Bg
Ch
Dquad
Attempts:
3 left
💡 Hint
Common Mistakes
Passing 'quad' instead of function names.
Using undefined function 'h'.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that computes areas for functions in funcs over 0 to 1.

SciPy
areas = { [1]: quad([2], 0, 1)[0] for [1] in [3] }
Drag options to blanks, or click blank then click option'
Afunc
Cfuncs
Df
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for key and function.
Using undefined variable 'f' instead of 'func'.