New job: decimal division
This commit is contained in:
parent
4c5e89aff7
commit
61ec23b3a4
31
jobs/decimal_division.py
Normal file
31
jobs/decimal_division.py
Normal file
@ -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)
|
||||||
@ -5,6 +5,7 @@ from jobs.unit_conversion import UnitConversionJob
|
|||||||
from jobs.chess_puzzle import ChessPuzzleJob
|
from jobs.chess_puzzle import ChessPuzzleJob
|
||||||
from jobs.maze import MazeJob
|
from jobs.maze import MazeJob
|
||||||
from jobs.division_cipher import DivisionCipherJob
|
from jobs.division_cipher import DivisionCipherJob
|
||||||
|
from jobs.decimal_division import DecimalDivisionJob
|
||||||
|
|
||||||
# ==========================================
|
# ==========================================
|
||||||
# CONFIGURATION
|
# CONFIGURATION
|
||||||
@ -55,7 +56,8 @@ JOBS = [
|
|||||||
UnitConversionJob(),
|
UnitConversionJob(),
|
||||||
ChessPuzzleJob(),
|
ChessPuzzleJob(),
|
||||||
MazeJob(),
|
MazeJob(),
|
||||||
DivisionCipherJob()
|
DivisionCipherJob(),
|
||||||
|
DecimalDivisionJob()
|
||||||
]
|
]
|
||||||
|
|
||||||
def run_tui():
|
def run_tui():
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user