ChatCrawlerпоиск по публичному Telegram Открыть приложение
О

Основы Python

снимок за апрель 2025
апрель 2025 ×
29 апреля 2025
Ответсообщение недоступно
from itertools import product f = input() f = f.replace('(', '( ').replace(')', ' )') op = ['(', ')', 'not', 'and', 'or', '^', '->', '~'] ar = f.split() stack = [] solve = [] di = {} for i in f: if i.isupper(): di[i] = 0 di = dict(sorted(di.items())) f = 0 for i in ar: if i.isupper(): solve.append(i) elif len(stack) == 0: stack.append(i) else: if i == ')': while stack[-1] != '(': solve.append(stack.pop(-1)) if stack[-1] == '(': del stack[-1] else: if op.index(i) < op.index(stack[-1]): stack.append(i) else: while len(stack) != 0 and stack[-1] != '(' and op.index(i) > op.index(stack[-1]): solve.append(stack.pop(-1)) stack.append(i) while len(stack) != 0: solve.append(stack.pop(-1)) res = [] for i in range(len(solve)): if solve[i].isupper(): res.append(solve[i]) else: if solve[i] == 'not': res[-1] = 'not(' + res[-1] + ')' elif solve[i] == 'and': a = res.pop(-1) b = res.pop(-1) res.append(f'({b}) and ({a})') elif solve[i] == 'or': a = res.pop(-1) b = res.pop(-1) res.append(f'({b}) or ({a})') elif solve[i] == '^': a = res.pop(-1) b = res.pop(-1) res.append(f'(({b}) or ({a})) % 2') elif solve[i] == '->': a = res.pop(-1) b = res.pop(-1) res.append(f'not({b}) or ({a})') elif solve[i] == '~': a = res.pop(-1) b = res.pop(-1) res.append(f'({b}) == ({a})') res_1 = res[0] var = [i for i in product([0, 1], repeat=len(di))] for i in di: print(i, end=' ') print('F') for i in var: index = 0 for j in di: di[j] = i[index] index += 1 for j in di: print(di[j], end=' ') print(int(eval(r
30 апреля 2025
Т
Ответсообщение недоступно
Фотография
нажмите — покажем
Фотография
нажмите — покажем
Фотография
нажмите — покажем
Фотография
нажмите — покажем
Фотография
нажмите — покажем
Всем привет ещё раз) Не могу разобраться с задачей про квадратное уравнение, вся программа работает до 14 проверки кода от Яндекса, вроде уже все «ответвления» проверил, все равно не работает( Прикрепляю код, делал с телефона, поэтому частями, заранее спасибо за помощь 🙏
Д
Т
Ответсообщение недоступно
a = float(input()) b = float(input()) c = float(input()) if a == 0: if b == 0 and c == 0: print('Infinite solutions') elif b == 0 and c != 0: print('No solution') elif b != 0 and c == 0: print(f'{c:.3}') elif b != 0 and c != 0: x = -c / b print(f'{x:.3}') elif a != 0: if b != 0: if c == 0: x = -b / a if x < 0: print(f'{x:.3} {c:.3}') elif x > 0: print(f'{c:.3} {x:.3}') elif c != 0: D = b * b - 4 * a * c if D > 0: x1 = (-b + D ** (1 / 2)) / (2 * a) x2 = (-b - D ** (1 / 2)) / (2 * a) if x1 > x2: print(f'{x2:.3} {x1:.3}') elif x1 < x2: print(f'{x1:.3} {x2:.3}') elif x1 == x2: print(f'{x1:.3}') elif D == 0: x = -b / 2 / a print(f'{x:.3}') elif D < 0: print('No solution') if b == 0: if c == 0: print(f'{c:.3}') elif c != 0: x1 = (-c / a) ** (1 / 2) x2 = -(-c / a) ** (1 / 2) if x1 > x2: print(f'{x2:.3} {x1:.3}') elif x1 < x2: print(f'{x1:.3} {x2:.3}')
Тёмаa = float(input()) b = float(input()) c = float(input()) if a == 0: if b == 0 and c == 0: print('Infinite solutions') elif b == 0 and c != 0: print('No solution') elif b != 0 and c == 0: print(f'{c:.3}') elif b != 0 and c != 0: x = -c / b prin
У меня получилось вот так a, b, c = float(input()), float(input()), float(input()) if a == 0 and b == 0 and c == 0: print('Infinite solutions') elif a == 0 and b == 0: print('No solution') elif a == 0 and c == 0: print(0) elif a == 0: print(f'{-c / b:.2f}') elif b == 0 and c == 0: print(0, 0) elif b == 0: if c < 0: print(f'{-(-c / a) ** 0.5:.2f}') else: print('No solution') elif c == 0: print(f'{min(0., -b / a):.2f}, {max(0., -b / a):.2f}') else: d = b * b - 4 * a * c if d < 0: print('No solution') elif d == 0: print(f'{-b / (2 * a):.2f}') else: x1 = (-b - d ** 0.5) / (2 * a) x2 = (-b + d ** 0.5) / (2 * a) print(f'{min(x1, x2):.2f} {max(x1, x2):.2f}')
С
Ответсообщение недоступно
Выбирая между кучей ветвлений и длинными условиями я выбрал более сложные условия, но при этом код, мне кажется, более наглядный
Открыть в Telegram Каталог площадок Искать в ChatCrawler

Слепок открытой публичной ленты из поискового индекса ChatCrawler — «Google по публичному Telegram»; обновляется по мере обхода площадки. Время — UTC.

Только публичный контент, официальный API Telegram. О проекте · Вопросы · Чего мы не делаем · Убрать страницу из выдачи · Каталог