
"""simple docstring"""


import math

import qiskit






def       _snake_case				(		snake_case__   :     int = 1	,      snake_case__   :     int = 1	,      snake_case__   :     int = 1     ):
	if (
	    isinstance(snake_case__	,      snake_case__     )
	    or isinstance(snake_case__	,      snake_case__     )
	    or isinstance(snake_case__	,      snake_case__     )
	):
		raise TypeError('inputs must be integers.'     )

	if (input_a < 0) or (input_a < 0) or (carry_in < 0):
		raise ValueError('inputs must be positive.'     )

	if (
	    (math.floor(snake_case__     ) != input_a)
	    or (math.floor(snake_case__     ) != input_a)
	    or (math.floor(snake_case__     ) != carry_in)
	):
		raise ValueError('inputs must be exact integers.'     )

	if (input_a > 2) or (input_a > 2) or (carry_in > 2):
		raise ValueError('inputs must be less or equal to 2.'     )

	# build registers
	A						   =   qiskit.QuantumRegister(4	,      'qr'     )
	A						   =   qiskit.ClassicalRegister(2	,      'cr'     )
	# list the entries
	A						   =   [input_a, input_a, carry_in]

	A						   =   qiskit.QuantumCircuit(snake_case__	,      snake_case__     )

	for i in range(0	,      3     ):
		if entry[i] == 2:
			quantum_circuit.h(snake_case__     )  # for hadamard entries
		elif entry[i] == 1:
			quantum_circuit.x(snake_case__     )  # for 1 entries
		elif entry[i] == 0:
			quantum_circuit.i(snake_case__     )  # for 0 entries

    # build the circuit
	quantum_circuit.ccx(0	,      1	,      3     )  # ccx = toffoli gate
	quantum_circuit.cx(0	,      1     )
	quantum_circuit.ccx(1	,      2	,      3     )
	quantum_circuit.cx(1	,      2     )
	quantum_circuit.cx(0	,      1     )

	quantum_circuit.measure([2, 3]	,      snake_case__     )  # measure the last two qbits

	A						   =   qiskit.Aer.get_backend('aer_simulator'     )
	A						   =   qiskit.execute(snake_case__	,      snake_case__	,      shots=1000     )

	return job.result().get_counts(snake_case__     )


if __name__ == "__main__":
		print(F"""Total sum count for state is: {quantum_full_adder(1, 1, 1)}""")

"""simple docstring"""


from json import JSONDecodeError  # Workaround for requests.exceptions.JSONDecodeError

import requests






def       _snake_case				(		snake_case__   :     str = "isbn/0140328726"     ):
	A						   =   olid.strip().strip('/'     )  # Remove leading/trailing whitespace & slashes
	if new_olid.count('/'     ) != 1:
		A						   =   F'{olid} is not a valid Open Library olid'
		raise ValueError(snake_case__     )
	return requests.get(F'https://openlibrary.org/{new_olid}.json'     ).json()






def       _snake_case				(		snake_case__   :     dict     ):
	A						   =   {
	    'title': 'Title',
	    'publish_date': 'Publish date',
	    'authors': 'Authors',
	    'number_of_pages': 'Number of pages:',
	    'first_sentence': 'First sentence',
	    'isbn_10': 'ISBN (10)',
	    'isbn_13': 'ISBN (13)',
	}
	A						   =   {better_key: ol_book_data[key] for key, better_key in desired_keys.items()}
	A						   =   [
	    get_openlibrary_data(author['key']     )['name'] for author in data['Authors']
	]
	A						   =   data['First sentence']['value']
	for key, value in data.items():
		if isinstance(snake_case__	,      snake_case__     ):
			A						   =   ', '.join(snake_case__     )
	return data


if __name__ == "__main__":
		import doctest

		doctest.testmod()

		while True:
				_lowercase							   =				input('''\nEnter the ISBN code to search (or \'quit\' to stop): ''').strip()
				if isbn.lower() in ("", "q", "quit", "exit", "stop"):
						break

				if len(isbn) not in (10, 13) or not isbn.isdigit():
						print(F"""Sorry, {isbn} is not a valid ISBN.  Please, input a valid ISBN.""")
						continue

				print(F"""\nSearching Open Library for ISBN: {isbn}...\n""")

				try:
						_lowercase							   =				summarize_book(get_openlibrary_data(F"""isbn/{isbn}"""))
						print('''\n'''.join(F"""{key}: {value}""" for key, value in book_summary.items()))
				except JSONDecodeError:  # Workaround for requests.exceptions.RequestException:
						print(F"""Sorry, there are no results for ISBN: {isbn}.""")