def comfort_count(temperatures):
count = 0
for temp in temperatures:
if 22 <= temp <= 26:
count += 1
returtn count
print(comfort_count(may_2017))
def comfort_count(temperatures):
return sum(1 for temp in temperatures if 22 <= temp <= 26)
def comfort_count(temperatures):
return sum(22 <= temp <= 26 for temp in temperatures)
def mastework(id_key, id_value):
id_join = {}
for k, v in zip(id_key, id_value):
id_join[k] = id_join.get(k, []) + [v]
return {k:v if len(v) > 1 else v[0] for k, v in id_join.items()}
ID_Masterok = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
ID_Master = ['Интендификатор мастера', '654', '2425', '654', '654', '—', '—', '—', '—', '—', '—']
ID_Mastework = mastework(ID_Master, ID_Masterok)
print(ID_Mastework)
In [55]:
{'Интендификатор мастера': 0, '654': [1, 3, 4], '2425': 2, '—': [5, 6, 7, 8, 9, 10]}
from re import findall
from itertools import zip_longest
def change_subs(text, old_sub, new_sub, pos=[1]):
subs = findall(old_sub, text)
for i in pos: subs[i-1] = new_sub
words = zip_longest(text.split(old_sub), subs, fillvalue='')
return ''.join(''.join(elem) for elem in words)
text = 'AAAAdfkjvsAAAA dsjfrfls d AAAAskdnfijdnAAAA kdferjnks AAAAjdfnjAAAA'
old = 'AAAA'
new = 'BB'
pos = [2,3,4]
a = change_subs(text, old, new, pos)
print(a)
In [28]:
AAAAdfkjvsBB dsjfrfls d BBskdnfijdnBB kdferjnks AAAAjdfnjAAAA
/ip firewall nat
add chain=srcnat action=src-nat to-addresses=ВАШ_ВНЕШНИЙ_IP to-ports=5060 protocol=udp src-address=ДОКАЛЬНЫЙ_IP_ТЕЛЕФОНА src-port=5060 out-interface=ВНЕШНИЙ_ИНТЕРФЕЙС
import re
dict_of_class = {}
for i in range(int(input())):
child, *parents = re.findall(r"[\w]+", input())
dict_of_class[child] = dict_of_class.get(child, []) + parents
print(dict_of_class)
def test_parent(child, parent):
if child in dict_of_class:
if parent in dict_of_class[child]:
return True
for par in dict_of_class[child]:
child = par
if test_parent(child, parent):
return True
return False
else:
return False
for i in range(int(input())):
parent, child = input().split()
print(('No', 'Yes')[test_parent(child, parent)])
In [8]:
4
A
B : A
C : A
D : B C
3
C D
A D
C A
{'A': [], 'B': ['A'], 'C': ['A'], 'D': ['B', 'C']}
Yes
Yes
No
def test_parent(par,ch):
.....
else:
test_parent(par,dict_of_class.get(ch)[i])