Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to display a simple LaTeX expression on a plot.
Matplotlib
import matplotlib.pyplot as plt plt.text(0.5, 0.5, r'$[1]$', fontsize=20, ha='center') plt.axis('off') plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the backslash before Greek letters.
Not using raw string notation r'' causing escape errors.
Omitting the $ signs around the LaTeX expression.
✗ Incorrect
The LaTeX expression must use backslash commands for Greek letters inside the math mode delimiters $...$.
2fill in blank
mediumComplete the code to plot the quadratic formula using LaTeX in the title.
Matplotlib
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [1, 4, 9]) plt.title(r'Quadratic formula: $x = \frac[1]{{2a}}$') plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using plus instead of minus before b.
Using plus instead of minus inside the square root.
Forgetting \pm symbol.
✗ Incorrect
The quadratic formula numerator is '-b ± sqrt(b^2 - 4ac)'.
3fill in blank
hardFix the error in the LaTeX expression to correctly display the integral in the plot label.
Matplotlib
import matplotlib.pyplot as plt plt.plot([0, 1], [0, 1]) plt.xlabel(r'Integral: $\int_0^1 f(x) dx = [1]$') plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Writing fractions without \frac{}{} syntax.
Repeating the integral expression instead of the result.
Using incomplete fraction commands like \frac12.
✗ Incorrect
The integral from 0 to 1 of f(x) dx equals 1/2, written as \frac{1}{2} in LaTeX.
4fill in blank
hardFill both blanks to create a LaTeX expression for the sum of squares in the plot text.
Matplotlib
import matplotlib.pyplot as plt plt.text(0.5, 0.5, r'Sum: $\sum_[1]=1}^n [2]^2$', fontsize=18, ha='center') plt.axis('off') plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variables for the index and the squared term.
Using n as the index variable instead of the upper limit.
Choosing uncommon index letters like k or j.
✗ Incorrect
The sum index is usually i, and the expression sums i squared from 1 to n.
5fill in blank
hardFill all three blanks to create a LaTeX expression for the binomial coefficient in the plot title.
Matplotlib
import matplotlib.pyplot as plt plt.title(r'Binomial coefficient: $\binom[1][2] = \frac[3]!}}{{k! (n-k)!}}$') plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping n and k in the binomial coefficient.
Using k! in numerator instead of n!.
Forgetting to match the factorial variable with the binomial coefficient top.
✗ Incorrect
The binomial coefficient is \binom{n}{k} = \frac{n!}{k! (n-k)!}.