0
0
SciPydata~10 mins

Factorial and gamma functions 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 calculate the factorial of 5 using scipy.

SciPy
from scipy.special import [1]
result = factorial(5)
print(result)
Drag options to blanks, or click blank then click option'
Acomb
Bgamma
Cfactorial
Dperm
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'gamma' instead of 'factorial' directly.
Trying to import from math instead of scipy.special.
2fill in blank
medium

Complete the code to calculate the gamma function value at 4.

SciPy
from scipy.special import [1]
result = gamma(4)
print(result)
Drag options to blanks, or click blank then click option'
Agamma
Bpsi
Cbeta
Dfactorial
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'factorial' instead of 'gamma' for non-integer inputs.
Confusing 'beta' function with gamma.
3fill in blank
hard

Fix the error in the code to correctly compute factorial of 7.

SciPy
from scipy.special import factorial
result = factorial([1])
print(result)
Drag options to blanks, or click blank then click option'
A'7'
B7
Cfactorial
Dgamma
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the number as a string like '7'.
Passing the function name instead of a number.
4fill in blank
hard

Fill both blanks to create a dictionary of factorials for numbers 1 to 5.

SciPy
from scipy.special import factorial
factorials = {i: [1](i) for i in range(1, [2])}
print(factorials)
Drag options to blanks, or click blank then click option'
Afactorial
Bgamma
C6
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using gamma instead of factorial for this task.
Using 5 as range end, which excludes 5.
5fill in blank
hard

Fill all three blanks to create a dictionary of gamma values for numbers 1 to 4.

SciPy
from scipy.special import gamma
values = [1]: [2](i) for i in range(1, [3])}
print(values)
Drag options to blanks, or click blank then click option'
Ai
Bgamma
C5
Dfactorial
Attempts:
3 left
💡 Hint
Common Mistakes
Using factorial instead of gamma.
Using 4 as range end, which excludes 4.