Created
November 20, 2022 20:51
-
-
Save chaliy/e9fd84e1b493530da8318bcb441495e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Герератор базових математичних завданнь |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lib import * | |
генератори = [ | |
створити_просте_множення(max=99), | |
створити_просте_мінусування(no_negative=True), | |
просте_додавання | |
] | |
завдання = [random.choice(генератори)() for i in range(20)] | |
друк_завдання(завдання) | |
друк_відповіді(завдання) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from lib import * | |
генератори = [ | |
створити_просте_ділення(), | |
створити_просте_множення(), | |
створити_просте_мінусування(), | |
просте_додавання | |
] | |
завдання = [random.choice(генератори)() for i in range(20)] | |
друк_завдання(завдання) | |
друк_відповіді(завдання) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def створити_просте_ділення(): | |
def просте_ділення(): | |
а = random.randrange(1, 9999) | |
б = random.randrange(1, int(а / (random.randrange(1, 3) * 10)) + 2) | |
exp = f"{а} / {б}" | |
остача = а % б | |
частка = int((а - остача) / б) | |
return [exp, f"{частка}, остача: {остача}"] | |
return просте_ділення | |
def створити_просте_множення(max=999): | |
def просте_множення(): | |
а = random.randrange(1, max) | |
б = random.randrange(1, max) | |
exp = f"{а} * {б}" | |
результат = а * б | |
return [exp, f"{результат}"] | |
return просте_множення | |
def створити_просте_мінусування(no_negative=False): | |
def просте_мінусування(): | |
а = random.randrange(1, 999) | |
б = random.randrange(1, а - 1) | |
exp = f"{а} - {б}" | |
результат = а - б | |
return [exp, f"{результат}"] | |
return просте_мінусування | |
def просте_додавання(): | |
а = random.randrange(1, 999) | |
б = random.randrange(1, 999) | |
exp = f"{а} + {б}" | |
результат = а + б | |
return [exp, f"{результат}"] | |
def друк_завдання(завдання): | |
print() | |
print("> Завдання:") | |
for [з,_] in завдання: | |
print(f'{з} = ') | |
def друк_відповіді(завдання): | |
print() | |
print("> Відповіді:") | |
for [з,в] in завдання: | |
print(f'{з} = {в}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment