multiplication-table.py
473 Bytes
#!/usr/bin/env python3
import random
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}$?
transform: ['trim']
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}. $$''')