spisok = ('много слов')
spisok = spisok.split()
spisokout = spisok[0] + spisok[1]
print(spisokout)
spisoklitera = []
for i in range(len(spisokout)):
spisoklitera.append(spisokout[i])
print(spisoklitera)
list('много слов') # => ['м', 'н', 'о', 'г', 'о', ' ', 'с', 'л', 'о', 'в']
mapping = str.maketrans(
"f,dult`;pbqrkvyjghcnea[wxio]sm'.z",
"абвгдеёжзийклмнопрстуфхцчшщъыьэюя",
)
calc = {
'квадрат': {
'площадь': lambda **kwargs: bottom ** 2,
'периметр':lambda **kwargs: bottom * 4,
},
'прямоугольник': {
'площадь': lambda **kwargs: bottom * height,
'периметр':lambda **kwargs: (bottom + height) * 2,
},
'треугольник': {
'площадь': lambda **kwargs: bottom * height / 2,
}
}
def ask(question, options=None, expected=str):
if options:
question = '{} ({}): '.format(question, '|'.join(options))
answer = None
while (options and answer not in options) or (type(answer) is not expected):
answer = input(question)
if expected is str:
answer = answer.lower().translate(mapping)
candidates = set(option for option in options if option.startswith(answer))
if len(candidates) == 1:
answer = candidates.pop()
else:
try:
answer = expected(answer)
except ValueError:
pass
return answer
if __name__ == '__main__':
figure = ask('Какую фигуру необходимо рассчитать?', set(calc))
parameter = ask('Какой параметр требуется вычислить?', set(calc[figure]))
bottom = ask('Введите длину основания: ', expected=float)
if figure == 'квадрат':
height = bottom
else:
height = ask('Введите высоту: ', expected=float)
result = calc[figure][parameter](bottom=bottom, height=height)
print(f'{parameter.title()} {figure}а: {result:.3f}')
L, W = map(int, input().split())
m=1
K=0
if W<L:
H=L
F=W
else:
H=W
F=L
for i in range(1,1001):
if H>2*m:
K=K+1
m=m*2
H=H/2
else:
T=K
for i in range(1,1001):
if F>2*m:
K=K+1
m=m*2
F=F/2
else:
T=K
print(T)
L, W = map(int, input().split())
h=1
k=0
while L>=2*h or W>=2*h:
if L>=W:
L=L/2
k+=1
else:
W=W/2
k+=1
h=2*h
print(k)
class Sheet:
def __init__(self, width, length, thickness=1, count=0):
self.width, self.length = sorted([width, length])
self.thickness = thickness
self.count = count
@property
def foldable(self):
return self.length >= 2 * self.thickness
def fold_once(self):
if self.foldable:
self.width, self.length = sorted([self.width, self.length/2])
self.thickness *= 2
self.count += 1
return True
else:
return False
def fold(self):
while self.fold_once():
pass
return self
def run_test_cases():
assert Sheet(82, 18).fold().count == 4
assert Sheet(404, 279).fold().count == 6
assert Sheet(10, 26).fold().count == 3
if __name__ == '__main__':
# run_test_cases()
with open('input.txt', 'rt') as fi, open('output.txt', 'wt') as fo:
dimensions = map(float, next(fi).split())
answer = Sheet(*dimensions).fold().count
print(answer, file=fo)