Two sets are equal if and only if every element of each set is contained in the other (each is a subset of the other). A set is less than another set if and only if the first set is a proper subset of the second set (is a subset, but is not equal). A set is greater than another set if and only if the first set is a proper superset of the second set (is a superset, but is not equal).
If multiple items are minimal, the function returns the first one encountered.
from django.core.cache import cache
IP_KEY = 'request_ban:{ip}'
DELAY = 3600
result = cache.get(IP_KEY.format(ip=ip))
if result:
difference = (result - datetime.datetime.now()).seconds
print(f'Вам осталось {difference} секунд')
else:
cache.set(
IP_KEY.format(ip=ip),
datetime.datetime.now() + datetime.timedelta(seconds=DELAY),
DELAY,
)
print('Добро пожаловать!')
try:
if {
'+': lambda o, t, h: o + t == h,
'-': lambda o, t, h: o - t == h,
'*': lambda o, t, h: o * t == h,
'/': lambda o, t, h: o / t == h,
}.get(j)(o, t, h):
print('YES')
else:
print('NO')
except KeyError:
print('Неизвестная функция')
except ZeroDivisionError:
print('Деление на ноль')