from pathlib import Path
from datetime import datetime
dic = {
datetime.fromtimestamp(path.stat().st_ctime).strftime('%Y-%m-%d %H:%M:%S'): path.name
for path in Path().glob('*.*')
}
path = min(Path().glob('*.rar'), key=lambda path: path.stat().st_ctime)
print(path.name)
(df.loc[0].value_counts() == df.loc[1].value_counts()).all()
set(df.loc[0]) == set(df.loc[1])
a = ['K', 'G', 'K', 'G', 'G', 'K', 'K']
chunks = list(zip(*[iter(a)]*2))
np.array([np.zeros((i, 2), dtype=np.float32) for i in input_list])
a = [{min(a): max(a), max(a): min(a)}.get(x, x) for x in a]
a[:] = map(lambda x: min(a) if x == max(a) else max(a) if x == min(a) else x, a)
d = {min(a), max(a)}
a[:] = (sum(d) - x if x in d else x for x in a)
d = {min(a), max(a)}
a[:] = ((d & {sum(d) - x} or {x}).pop() for x in a)
from operator import itemgetter
(i_min, v_min), *_, (i_max, v_max) = sorted(enumerate(a), key=itemgetter(1))
a[i_min], a[i_max] = v_max, v_min
i_min, v_min = min(enumerate(a), key=itemgetter(1))
i_max, a[i_min] = max(enumerate(a), key=itemgetter(1))
a[i_max] = v_min
import random
from collections import defaultdict
class mydefaultdict(defaultdict):
def __getattr__(self, attr):
return self[attr]
def __setattr__(self, attr, val):
self[attr] = val
def classify(self, animal, unknown='Unknown'):
for subclass, species in self.items():
if animal in species:
return subclass
return unknown
@property
def all(self):
all_animals = []
for subclass, species in self.items():
all_animals.extend(species)
return all_animals
@property
def random(self):
return random.choice(self.all)
def taxonomy():
return mydefaultdict(taxonomy)
animals = tree()
animals.cats.Tiger
animals.cats.Lion
animals.horses.Zebra
animals.horses.Horse
animals.horses.Lamb
animals.birds.Raven
animals.birds.Parrot
animals.birds.Dove
animals.elephants.Elephant
animals.dogs.Wolf
animals.dogs.Hyena
random_animal = animals.random
answer = input(f'What class does {random_animal} animal belong to? ')
correct_answer = animals.classify(random_animal)
print(['Не верно', 'Верно'][answer == correct_answer])