random.choice(['Red','Black'],[5,25], k=100)
import datetime
past = datetime.datetime(2022,11,25,16,55,32)
now = datetime.datetime.now()
mappings = {'Дней: ':60*60*24, 'Часов: ':60*60, 'Минут: ': 60,'Секунд: ':1}
diff_in_seconds = int((now - past).total_seconds())
result = ''
for key, value in mappings.items():
result += key + str(diff_in_seconds // value) + ', '
diff_in_seconds %= value
print(f'Разница между {past} и {now} состовляет {result}')
import random
result = {}
for n in range(10):
experiment = []
while True:
experiment.append('О' if random.random() < 0.5 else 'Р')
for i in range(len(experiment) - 2):
if (experiment[i] == experiment[i+1]) and (experiment[i+1] == (experiment[i+2])):
break
else:
continue
break
result[f'Попытка Номер {n+1}'] = experiment
print(result)
import math
def convert(a,b):
p = math.floor(math.log10(a))
if a < 1:
result = '0.' + str(abs(p+1)*'0') + str(b)
return result
print(convert(0.0601,535))
print(convert(0.00601,535))
print(convert(0.000601,535))
p = math.floor(math.log10(a))