multiplication-table.py 551 Bytes
#!/usr/bin/env python3

import random
import sys

# can be repeated
# x = random.randint(2, 9)
# y = random.randint(2, 9)

# with x != y
x, y = random.sample(range(2,10), k=2)
r = x * y

yy = '+'.join([str(y)]*x)
xx = '+'.join([str(x)]*y)

print(f'''---
type: text
title: Multiplicação (tabuada)
text: |
  Qual o resultado da multiplicação ${x}\\times {y}$?
correct: ['{r}']
solution: |
  A multiplicação é a repetição da soma. Podemos fazer de duas maneiras:
  $$ {x}\\times {y} = {yy} = {r} $$
  ou
  $$ {y}\\times {x} = {xx} = {r}. $$''')