>>> import random
>>>
>>> vars = ['yes', 'no']
>>> random.choices(vars, weights=[0.9, 0.1])
['yes']
>>> random.choices(vars, weights=[0.9, 0.1])
['yes']
>>> random.choices(vars, weights=[0.9, 0.1])
['no']
>>> random.choices(vars, weights=[0.9, 0.1])
['yes']
>>> random.choices(vars, weights=[0.9, 0.1])
['yes']
>>>
>>> import pandas as pd
>>>
>>> df1 = pd.DataFrame({'item': [1, 2, 3, 4], 'val1': [213, 31, 12, 2132], 'val2': [54, 322, 23, 23]})
>>> df2 = pd.DataFrame({'item': [1, 2, 3, 4], 'val1': [213, 31, 12, 2132], 'val2': [32112, 132412, 1354112, 123412]})
>>>
>>> df1 = df1[['item', 'val1']]
>>> df2 = df2[['item', 'val2']]
>>>
>>> df = df1.merge(df2, on='item', how='inner')
>>> df
item val1 val2
0 1 213 32112
1 2 31 132412
2 3 12 1354112
3 4 2132 123412
>>>
from collections import defaultdict
from pprint import pprint
strange_lists = [['Егор', '1', 'Вася', '0'], ['Петя', '4', 'Вася', '5'], ['Егор', '2', 'Петя', '2'], ['Никита', '4', 'Андрей', '4']]
counter = defaultdict(int)
for strange_list in strange_lists:
for i in strange_list:
try:
int(i)
continue
except ValueError:
pass
counter[i] += 1
pprint(counter)
# defaultdict(<class 'int'>,
# {'Андрей': 1,
# 'Вася': 2,
# 'Егор': 2,
# 'Никита': 1,
# 'Петя': 2})
print(
" ".join([input(f"Input your {i}: ") for i in ["name", "last name"]])
+ "\n"
+ input("Input your birth date: ")
+ "\n"
+ " ".join([input(f"Input your {i}: ") for i in ["user name", "password"]])
)
# Input your name: di
# Input your last name: k
# Input your birth date: 26
# Input your user name: w
# Input your password: sakfjs
# di k
# 26
# w sakfjs
if 'some' in text:
import re
MY_RE = re.compile(f'some pattern')
class Register:
user_response = MY_RE.findall(self.text)
# Keep main program running while bot runs threaded
if __name__ == "__main__":
while True:
try:
sleep(120)
except KeyboardInterrupt:
break
class InterfaceInteraction(classmethod):