thermoprint-homework/jobs/decimal_division.py
2025-12-23 14:40:57 +01:00

31 lines
953 B
Python

import random
from .base import Job
class DecimalDivisionJob(Job):
def get_name(self):
return "DELENI (2 DES. MISTA)"
def print_body(self, p):
p.text("Vypocitej na 2 desetinna mista:\n\n")
results = []
exercises = 2;
for i in range(1, exercises + 1):
# Ensure it's not too easy (avoid 1)
divisor = random.randint(2, 39)
# Dividend between 10 and 100
dividend = random.randint(10, 1000)
p.text(f"{i}) {dividend} : {divisor} = ______\n\n")
# Calculate result rounded to 2 decimal places
res = dividend / divisor
results.append(f"{i}) {res:.2f}")
p.text("\n\n\n\n") # add space for calculations
p.text("Reseni (naskenuj):\n")
# Join results for the QR code
qr_data = "\n".join(results)
p.qr(qr_data, size=6, native=True)