Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'gamma' instead of 'factorial' directly.
Trying to import from math instead of scipy.special.
✗ Incorrect
The factorial function from scipy.special calculates the factorial of a number.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'factorial' instead of 'gamma' for non-integer inputs.
Confusing 'beta' function with gamma.
✗ Incorrect
The gamma function generalizes factorial to real and complex numbers. gamma(4) equals 3! = 6.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the number as a string like '7'.
Passing the function name instead of a number.
✗ Incorrect
The factorial function expects an integer input, not a string. Use 7 without quotes.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using gamma instead of factorial for this task.
Using 5 as range end, which excludes 5.
✗ Incorrect
Use factorial function and range up to 6 to include 5.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using factorial instead of gamma.
Using 4 as range end, which excludes 4.
✗ Incorrect
Use i as key, gamma function for values, and range end 5 to include 4.