0
0
SciPydata~10 mins

Error function (erf) in SciPy - Interactive Code Practice

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

Complete the code to import the error function from scipy.special.

SciPy
from scipy.special import [1]

result = erf(1.0)
print(result)
Drag options to blanks, or click blank then click option'
Aerror_function
Berror_func
Cerf
Dspecial_erf
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to import a non-existent function name like 'error_func'.
Using a wrong module instead of scipy.special.
2fill in blank
medium

Complete the code to calculate the error function value for 0.5.

SciPy
from scipy.special import erf

value = erf([1])
print(value)
Drag options to blanks, or click blank then click option'
A0.5
B1.0
C2.0
D-0.5
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1.0 or 2.0 instead of 0.5.
Passing a negative value when positive was asked.
3fill in blank
hard

Fix the error in the code to correctly compute the error function for an array of values.

SciPy
import numpy as np
from scipy.special import erf

arr = np.array([0, 0.5, 1.0])
result = [1](arr)
print(result)
Drag options to blanks, or click blank then click option'
Aerror_func
Berf_array
Cspecial_erf
Derf
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent function name like 'error_func'.
Trying to call a method that does not exist on numpy arrays.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps numbers to their error function values for numbers greater than 0.

SciPy
from scipy.special import erf

numbers = [-1, 0, 0.5, 1]
erf_values = {num: [1](num) for num in numbers if num [2] 0}
print(erf_values)
Drag options to blanks, or click blank then click option'
Aerf
B>
C<
Dabs
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' in the condition.
Using 'abs' instead of 'erf' for the function.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps the uppercase string of numbers to their error function values if the value is positive.

SciPy
from scipy.special import erf

numbers = {'a': 0.5, 'b': -0.5, 'c': 1.0}
erf_dict = { [1]: [2] for key, val in numbers.items() if val [3] 0 }
print(erf_dict)
Drag options to blanks, or click blank then click option'
Akey.upper()
Bval
C>
Derf(val)
Attempts:
3 left
💡 Hint
Common Mistakes
Using val instead of erf(val) for the dictionary values.
Not converting keys to uppercase.
Using '<' instead of '>' in the condition.