A
Size: a a a
A
БГ
<Ч
E
БГ
A
E
БГ
A
from calculator import calc #тут импортируется произвольный код невъебенного калькулятора не ломающего систему
try:
print(calc(input("Введите выражение:")))
except Exception as e:
print(f"Произошла ошибка: {e}")
AT
def matmul_short(n):
r = [1] + list(range(1, n + 1))
w = len(str(n ** 2))
t = f"{{:>{w}}}"
return t.format('_') + '\n'.join('|'.join(t.format(x * y) for x in r) for y in r)[w:]
E
from calculator import calc #тут импортируется произвольный код невъебенного калькулятора не ломающего систему
try:
print(calc(input("Введите выражение:")))
except Exception as e:
print(f"Произошла ошибка: {e}")
A
БГ
БГ
E
AT
ops = {
'+': lambda x, y: x + y,
'-': lambda x, y: x - y,
'/': lambda x, y: x / y if y != 0 else 'undefined',
'*': lambda x, y: x * y,
}
for sign, op in ops.items():
for num1 in range(51):
for num2 in range(51):
text += f"if num1 == {num1} and sign == '{sign}' and num2 == {num2}:\n"\
f' print("{num1}{sign}{num2} = {op(num1, num2)}")\n'
text += 'print("Thanks for using this calculator, goodbye :)")'
with open('MEGACALC.py', 'w') as file:
file.write(text)E
ops = {
'+': lambda x, y: x + y,
'-': lambda x, y: x - y,
'/': lambda x, y: x / y if y != 0 else 'undefined',
'*': lambda x, y: x * y,
}
for sign, op in ops.items():
for num1 in range(51):
for num2 in range(51):
text += f"if num1 == {num1} and sign == '{sign}' and num2 == {num2}:\n"\
f' print("{num1}{sign}{num2} = {op(num1, num2)}")\n'
text += 'print("Thanks for using this calculator, goodbye :)")'
with open('MEGACALC.py', 'w') as file:
file.write(text)K
БГ
ops = {
'+': lambda x, y: x + y,
'-': lambda x, y: x - y,
'/': lambda x, y: x / y if y != 0 else 'undefined',
'*': lambda x, y: x * y,
}
for sign, op in ops.items():
for num1 in range(51):
for num2 in range(51):
text += f"if num1 == {num1} and sign == '{sign}' and num2 == {num2}:\n"\
f' print("{num1}{sign}{num2} = {op(num1, num2)}")\n'
text += 'print("Thanks for using this calculator, goodbye :)")'
with open('MEGACALC.py', 'w') as file:
file.write(text)R3
import operator
try:
o = input(); a, b = map(int, [input(), input()]); op={'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv}.get(o, lambda a, b: raise ValueError("Fuck you, pick proper operator))(a, b)
except (ValueError, ZeroDivisionError) as e:
print(e)