


import math as m


def 	_UpperCamelCase							(				lowercase__   ,	lowercase__   ,	lowercase__=0.001				):
						return (f(a + h				) - f(a - h				)) / (2 * h)


def 	_UpperCamelCase							(				lowercase__   ,	lowercase__=0   ,	lowercase__=100   ,	lowercase__=0.0001   ,	lowercase__=1e-6   ,	lowercase__=False				):
						__SCREAMING_SNAKE_CASE						:					Dict		      =		xa  # set the initial guess
						__SCREAMING_SNAKE_CASE						:					str		      =		[a]
						__SCREAMING_SNAKE_CASE						:					List[str]		      =		abs(f(_A				)				)
						__SCREAMING_SNAKE_CASE						:					Union[str, Any]		      =		lambda lowercase__				: calc_derivative(_A   ,	_A   ,	h=_A				)  # noqa: E731  Derivative of f(x)
						for _ in range(_A				):
												if fa(_A				) == 0:
																		raise ValueError('''No converging solution found'''				)
												__SCREAMING_SNAKE_CASE						:					Optional[int]		      =		a - f(_A				) / fa(_A				)  # Calculate the next estimate
												if logsteps:
																		steps.append(_A				)
												if error < maxerror:
																		break
						else:
												raise ValueError('''Iteration limit reached, no converging solution found'''				)
						if logsteps:
												# If logstep is true, then log intermediate steps
												return a, error, steps
						return a, error


if __name__ == "__main__":
						from matplotlib import pyplot as plt

						__lowerCAmelCase     :			List[Any]      =lambda x: m.tanh(x) ** 2 - m.exp(3 * x)  # noqa: E731
						__lowerCAmelCase    ,__lowerCAmelCase    ,__lowerCAmelCase     :			Union[str, Any]      =newton_raphson(
						    f, xa=1_0, maxiter=1_0_0_0, step=1e-6, logsteps=True
						)
						plt.plot([abs(f(x)) for x in steps])
						plt.xlabel('step')
						plt.ylabel('error')
						plt.show()
						print(f"""solution = {{{solution:f}}}, error = {{{error:f}}}""")








def 	_UpperCamelCase							(				lowercase__				):
						barcode //= 10  # exclude the last digit
						__SCREAMING_SNAKE_CASE						:					Optional[Any]		      =		False
						__SCREAMING_SNAKE_CASE						:					Dict		      =		0

						# extract and check each digit
						while barcode != 0:
												__SCREAMING_SNAKE_CASE						:					int		      =		1 if checker else 3
												s += mult * (barcode % 10)
												barcode //= 10
												__SCREAMING_SNAKE_CASE						:					Dict		      =		not checker

						return (10 - (s % 10)) % 10


def 	_UpperCamelCase							(				lowercase__				):
						return len(str(lowercase__				)				) == 13 and get_check_digit(lowercase__				) == barcode % 10


def 	_UpperCamelCase							(				lowercase__				):
						if str(lowercase__				).isalpha():
												__SCREAMING_SNAKE_CASE						:					str		      =		F'''Barcode \'{barcode}\' has alphabetic characters.'''
												raise ValueError(lowercase__				)
						elif int(lowercase__				) < 0:
												raise ValueError('''The entered barcode has a negative value. Try again.'''				)
						else:
												return int(lowercase__				)


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						__lowerCAmelCase     :			Union[str, Any]      =get_barcode(input('Barcode: ').strip())

						if is_valid(barcode):
												print(f"""'{barcode}' is a valid barcode.""")
						else:
												print(f"""'{barcode}' is NOT a valid barcode.""")
