<jupyter_start><jupyter_text>Quantum EntanglementExploring the basics of qiskit by setting up 2 qubits in entanglement---Done as part of the NPTEL Course - Introduction to Quantum Computing: Quantum Algorithms and Qiskithttps://onlinecourses.nptel.ac.in/noc21_cs103/preview<jupyter_code># Importingstandard Qiskit libraries
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.compiler import transpile, assemble
from qiskit.tools.jupyter import *
from qiskit.visualization import plot_histogram
from ibm_quantum_widgets import *

# Loading the IBM Q Account
provider = IBMQ.load_account()
print("Process Complete!")
# Creating a Quantum Circuit with 2 Qubits (Q0, C0) and 2 Classical Registers (Q1, C1)
qc = QuantumCircuit(2,2)

# Applying Hadamard on the 0th Qubit
qc.h(0)

# CNOT Gate with the source as the 0th Qubit and the target as the 1st Qubit 
qc.cx(0,1)

# Map Q0 to C0 and Q1 to C1
qc.measure( range(2), range(2) )

qc.draw()
# Simulation (Aer is for simulations)

# Defining a backend which mentions where to run the Quantum Circuit (Using the qasm simulator for now)
backend = Aer.get_backend('qasm_simulator')
job_simulator = execute(qc, backend, shots = 1024)

results_simulator = job_simulator.result()
counts = results_simulator.get_counts(qc)

print("Counts:", counts)

plot_histogram(counts)
provider.backends() # backends available to this account
# Actually running it on a Quantum Computer (same code as before)

backend = provider.get_backend("ibmq_belem")
job_simulator = execute(qc, backend, shots = 1024)

results_simulator = job_simulator.result()
counts = results_simulator.get_counts(qc)

print("Counts:", counts)

plot_histogram(counts)<jupyter_output>Counts: {'00': 464, '01': 43, '10': 56, '11': 461}
{'fraction_non_alphanumeric': 0.09221076746849943, 'fraction_numerical': 0.029782359679266894, 'mean_word_length': 5.850980392156862, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '201202', 'license': 'MIT', 'n_tokens_mistral': 645, 'n_tokens_neox': 573, 'n_words': 189, 'path': 'Fundamentals/1_Entanglement.ipynb', 'repo_name': 'Chasmiccoder/IBM-Quantum-Challenges', 'size': '1746'}