diff --git a/jobs/decimal_division.py b/jobs/decimal_division.py new file mode 100644 index 0000000..b0cffe0 --- /dev/null +++ b/jobs/decimal_division.py @@ -0,0 +1,31 @@ +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) \ No newline at end of file diff --git a/print_server.py b/print_server.py index fdd383f..73923e6 100644 --- a/print_server.py +++ b/print_server.py @@ -5,6 +5,7 @@ from jobs.unit_conversion import UnitConversionJob from jobs.chess_puzzle import ChessPuzzleJob from jobs.maze import MazeJob from jobs.division_cipher import DivisionCipherJob +from jobs.decimal_division import DecimalDivisionJob # ========================================== # CONFIGURATION @@ -55,7 +56,8 @@ JOBS = [ UnitConversionJob(), ChessPuzzleJob(), MazeJob(), - DivisionCipherJob() + DivisionCipherJob(), + DecimalDivisionJob() ] def run_tui():