Code and KaTeX Support

Using Code and Math in Flashcards

KardSkript isn’t just for text! You can add programming code snippets and LaTeX-style math equations using KaTeX. This is perfect for students who want to practice math or coding directly in their flashcards.

  • Use the code property to embed syntax-highlighted code blocks.
  • Use the equationBack property to render KaTeX math equations.
  • Combine text, code, and math for powerful study cards in STEM subjects.
flash({
  front: "Vector notation in math",
  back: "A vector is written as a column or row of numbers.",
  equationBack: `\vec{v} = \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix}`
})

flash({
  front: "What is a vector in NumPy?",
  back: "A 1D array representing a mathematical vector.",
  code: `import numpy as np

vector_a = np.array([1, 2, 3])
vector_b = np.array([4, 5, 6])

print("Vector A:", vector_a)
print("Vector B:", vector_b)`
})

flash({
  front: "How to create a matrix in NumPy?",
  back: "Use a 2D array to represent a matrix.",
  code: `import numpy as np

matrix_a = np.array([[1, 2], [3, 4]])
matrix_b = np.array([[5, 6], [7, 8]])

print("Matrix A:\\n", matrix_a)
print("Matrix B:\\n", matrix_b)`
})

flash({
  front: "What is an identity matrix?",
  back: "A square matrix with ones on the diagonal and zeros elsewhere.",
  code: `import numpy as np

identity_matrix = np.identity(3)
print("Identity Matrix:\\n", identity_matrix)`
})

flash({
  front: "What is a diagonal matrix?",
  back: "A matrix with non-zero values only on the diagonal.",
  code: `import numpy as np

diagonal_matrix = np.diag([1, 2, 3])
print("Diagonal Matrix:\\n", diagonal_matrix)`
})

flash({
  front: "What is a zero matrix?",
  back: "A matrix with all elements equal to zero.",
  code: `import numpy as np

zero_matrix = np.zeros((3, 3))
print("Zero Matrix:\\n", zero_matrix)`,
  y:1000
})

flash({
  front: "Matrix multiplication rule",
  back: "If A is an m×n matrix and B is an n×p matrix, then AB is an m×p matrix.",
  equationBack: `(AB)_{ij} = \sum_{k=1}^{n} A_{ik} B_{kj}`
})
Vector notation in math
A vector is written as a column or row of numbers.
v⃗=[v1v2v3]\vec{v} = \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix}
What is a vector in NumPy?
A 1D array representing a mathematical vector.
import numpy as np

vector_a = np.array([1, 2, 3])
vector_b = np.array([4, 5, 6])

print("Vector A:", vector_a)
print("Vector B:", vector_b)
How to create a matrix in NumPy?
Use a 2D array to represent a matrix.
import numpy as np

matrix_a = np.array([[1, 2], [3, 4]])
matrix_b = np.array([[5, 6], [7, 8]])

print("Matrix A:\n", matrix_a)
print("Matrix B:\n", matrix_b)
What is an identity matrix?
A square matrix with ones on the diagonal and zeros elsewhere.
import numpy as np

identity_matrix = np.identity(3)
print("Identity Matrix:\n", identity_matrix)
What is a diagonal matrix?
A matrix with non-zero values only on the diagonal.
import numpy as np

diagonal_matrix = np.diag([1, 2, 3])
print("Diagonal Matrix:\n", diagonal_matrix)
What is a zero matrix?
A matrix with all elements equal to zero.
import numpy as np

zero_matrix = np.zeros((3, 3))
print("Zero Matrix:\n", zero_matrix)
Matrix multiplication rule
If A is an m×n matrix and B is an n×p matrix, then AB is an m×p matrix.
(AB)ij=∑k=1nAikBkj(AB)_{ij} = \sum_{k=1}^{n} A_{ik} B_{kj}