




'''simple docstring'''





from math import factorial





def       __a      (  _UpperCamelCase:       int   ,		_UpperCamelCase:       int   ,		_UpperCamelCase:       float       )		->					float:

     """simple docstring"""




     if successes > trials:
          raise ValueError("successes must be lower or equal to trials"       )
     if trials < 0 or successes < 0:
          raise ValueError("the function is defined for non-negative integers"       )
     if not isinstance(_UpperCamelCase   ,		_UpperCamelCase       ) or not isinstance(_UpperCamelCase   ,		_UpperCamelCase       ):
          raise ValueError("the function is defined for non-negative integers"       )
     if not 0 < prob < 1:
          raise ValueError("prob has to be in range of 1 - 0"       )
     _snake_case				= (prob**successes) * ((1 - prob) ** (trials - successes))
     # Calculate the binomial coefficient: n! / k!(n-k)!
     _snake_case				= float(factorial(_UpperCamelCase       )       )
     coefficient /= factorial(_UpperCamelCase       ) * factorial(trials - successes       )
     return probability * coefficient


if __name__ == "__main__":
   from doctest import testmod

   testmod()
   print('''Probability of 2 successes out of 4 trails''')
   print('''with probability of 0.75 is:''', end=''' ''')
   print(binomial_distribution(2, 4, 0.7_5))








'''simple docstring'''





from __future__ import annotations

import collections
import pprint
from pathlib import Path





def       __a      (  _UpperCamelCase:       str       )		->					str:

     """simple docstring"""




     return "".join(sorted(_UpperCamelCase       )       )





def       __a      (  _UpperCamelCase:       str       )		->					list[str]:

     """simple docstring"""




     return word_by_signature[signature(_UpperCamelCase       )]


UpperCamelCase_		:     str          =		Path(__file__).parent.joinpath('''words.txt''').read_text(encoding='''utf-8''')
UpperCamelCase_		:     Dict          =		sorted({word.strip().lower() for word in data.splitlines()})

UpperCamelCase_		:     Optional[Any]          =		collections.defaultdict(list)
for word in word_list:
   word_by_signature[signature(word)].append(word)

if __name__ == "__main__":
   UpperCamelCase_		:     List[str]          =		{word: anagram(word) for word in word_list if len(anagram(word)) > 1}

   with open('''anagrams.txt''', '''w''') as file:
      file.write('''all_anagrams = \n ''')
      file.write(pprint.pformat(all_anagrams))


