



from PIL import Image



def    _lowerCAmelCase    (_lowerCAmelCase):
					UpperCamelCase_  ,    UpperCamelCase_		  =   image.size
					UpperCamelCase_		  =   0
					UpperCamelCase_		  =   image.load()
					for i in range(_lowerCAmelCase):
										for j in range(_lowerCAmelCase):
															UpperCamelCase_		  =   pixels[j, i]
															mean += pixel
					mean //= width * height

					for j in range(_lowerCAmelCase):
										for i in range(_lowerCAmelCase):
															UpperCamelCase_		  =   2_55 if pixels[i, j] > mean else 0
					return image


if __name__ == "__main__":
	UpperCAmelCase   :							Any							 =mean_threshold(Image.open("""path_to_image""").convert("""L"""))
	image.save("""output_image_path""")





from __future__ import annotations



def    _lowerCAmelCase    (_lowerCAmelCase   ,	_lowerCAmelCase):
					if nth_term == "":
										return [""]
					UpperCamelCase_		  =   int(_lowerCAmelCase)
					UpperCamelCase_		  =   int(_lowerCAmelCase)
					UpperCamelCase_		  =   []
					for temp in range(int(_lowerCAmelCase)):
										series.append(f"""1 / {pow(temp + 1   ,	int(_lowerCAmelCase))}""" if series else "1")
					return series


if __name__ == "__main__":
	import doctest

	doctest.testmod()

	UpperCAmelCase   :							Dict							 =int(input("""Enter the last number (nth term) of the P-Series"""))
	UpperCAmelCase   :							Union[str, Any]							 =int(input("""Enter the power for  P-Series"""))
	print("""Formula of P-Series => 1+1/2^p+1/3^p ..... 1/n^p""")
	print(p_series(nth_term, power))
