def solve_equation(a,b): # x - a(x div b) = b
if a%1 + b%1 != 0:
raise ValueError('both variables must have integer values')
if 0 < a < b: x = a + b
else: x = None
return x
В том смысле, что для любых a < b ответ: a + b. Для всех прочих - решение отсутствует. turtle._root.mainloop()
from math import factorial as fact
def sigma(n,x):
if abs(x) in range(abs(n)+1):
raise ValueError('check the arguments values ')
else:
return sum(
[(-1)**(n-k)*fact(2*n)/fact(n+k)/fact(n-k)/(x-k)
for k in map(lambda i: i-n, range(2*n+1))]
)
from os import startfile
from psutil import process_iter
from time import sleep
def is_completed(some_attribute):
#if <your cheking method>: return True
#else: return False
startfile(some_file)
while not is_completed(some_attribute):
sleep(some_time)
for proc in process_iter():
if proc.name() == some_file.split("\\")[-1]:
proc.kill()
string = """('OK', [b'(\\Inbox) "/" "INBOX"', b'() "/" "&BCIENQRBBEIEPgQyBEsENQ- &BEIENQQ7BDUEMwRABDAEPAQ8BEs-"', b'(\\Spam) "/" "&BCEEPwQwBDw-"', b'(\\Sent) "/" "&BB4EQgQ,BEAEMAQyBDsENQQ9BD0ESwQ1-"', b'(\\Drafts) "/" "&BCcENQRABD0EPgQyBDgEOgQ4-"', b'(\\Trash) "/" "&BBoEPgRABDcEOAQ9BDA-"', b'(\\NoInferiors) "/" "INBOX/Social"', b'(\\NoInferiors) "/" "INBOX/News Letters"'])"""
res = []
st_rest = string.partition('''/" "''')[2]
while st_rest != '':
part = st_rest.partition(""""'""")
res.append(part[0])
st_rest = part[2].partition('''/" "''')[2]
for r in res: print(r)
# INBOX
# &BCIENQRBBEIEPgQyBEsENQ- &BEIENQQ7BDUEMwRABDAEPAQ8BEs-
# &BCEEPwQwBDw-
# &BB4EQgQ,BEAEMAQyBDsENQQ9BD0ESwQ1-
# &BCcENQRABD0EPgQyBDgEOgQ4-
# &BBoEPgRABDcEOAQ9BDA-
# INBOX/Social
# INBOX/News Letters
...наверняка можно написать и более толково, но, как по мне, так тут проблемы вообще нету.def parse(html):
soup = BeautifulSoup(html, "html.parser")
div = soup.find("div", id="wrapper")
diver = div.find("div", id="content")
content = diver.findAll("div", class_="boxcontent")
data_lst = content[2].findAll("tr")
for field in data_lst:
f = field.findAll("td")
print('%s\t%s\t%s' % tuple(map(lambda t: t.text.strip(), f)))
##Имя: Юлия
##Контактный телефон: +375257784933
##Мобильный телефон: +375257784933
...
for k in range(0,c)[::-1]:
m = Array_counter[k]
print("Индекс элемента с нулевым значением = ", m)
del(array[m]) # удаляем 0 с индексом m
...
from itertools import combinations
def ungroup(data_list, limit):
data_list.sort()
result_list = []
while sum(data_list) > limit:
series = [data_list.pop()]
rest = limit - series[0]
if rest == 0:
result_list.append(series)
elif rest in data_list:
result_list.append(series + [data_list.pop(data_list.index(rest))])
else:
sublist = data_list.copy()
for i in data_list:
if i > rest:
sublist = data_list[:data_list.index(i)]
break
for n in range(2, len(sublist)):
comb = {sum(i): i for i in combinations(sublist, n)}
if rest in comb.keys():
series.extend(comb[rest])
for i in comb[rest]: data_list.remove(i)
break
result_list.append(series)
if len(data_list) > 0:
result_list.append(data_list)
return result_list
print(ungroup([6, 4, 4, 3, 2, 1.5, 1, 0.5], 6))
# [[6], [4, 2], [4, 0.5, 1.5], [1, 3]]
from tkinter import *
from time import sleep
window = Tk()
c = Canvas(window, width=800, height=500, bg='darkblue')
c.pack()
def text_show():
c.create_text(400,250, text='You win!',\
font=('Helvetica', 30), fill='white')
window.update_idletasks()
sleep(5)
exit()
c.after(500, text_show) # in milliseconds
import urllib.request
from urllib.parse import quote
api_id = ########-####-####-####-############
phone = ############
text = quote('Привет, Toster!', '&=' )
url = 'https://sms.ru/sms/send?api_id=%s&to=%d&msg=%s' % (api_id, phone, text)
urllib.request.urlopen(url)