New job: decimal division
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user