<jupyter_start><jupyter_text>Getting started with Qiskit Original source: [Documentation](https://qiskit.org/documentation/tutorials/circuits/1_getting_started_with_qiskit.html) Installing Qiskit textbook packages See README.md  Before you deep dive into the code, check the following definition:- Qubit: A qubit is a quantum bit.- Qiskit: A software development toolkit to work with quantum computers In quantum mechanics, instead of using normal probabilities, we use $\textit{probability amplitudes}$. Amplitudes are similar to probabilities as each outcome has a $\textbf{magnitude}$ which tells how likely the outcome is to occur. However, amplitudes have an another additional property: $\textbf{phase}$ which tells the direction.More info can be found [here](https://learn.qiskit.org/course/introduction/what-is-quantum).  Exercise 1:If you have $n$ qubits, how many possible outcomes are there? Exercise 2:If you want to predict the behaviour of $n$ qubits using vectors like those above, you need to keep track of at most __ amplitudes.  Workflow of Qiskit- Build: Design a quantum circuit(s) that represents the problem at hand.- Execute: Compile and run circuits in different background such as in a specific quantum system or classical simulator.We will go through some examples here.  Build We import the following routines from the Qiskit library:- QuantumCircuit: This routine is used to create a quantum circuit. Here, we generate our first quantum circuit with 2 qubits and 2 outputs.<jupyter_code>from qiskit import QuantumCircuit
n = 2
n_q = n # quibits
n_b = n # output
qc_output = QuantumCircuit(n_q, n_b)
qc_output.draw()<jupyter_output><empty_output><jupyter_text>We don't see anything yet!The extraction of outputs in QC is done using an operation called $\textit{measure}$. Each measurement tells a specific qubit to give an output to a specific output bit.The command qc_output.measure(j, j) tells qubit j to write an output to bit j.<jupyter_code>for j in range(n):
    qc_output.measure(j,j)<jupyter_output><empty_output><jupyter_text>Now, see the difference!<jupyter_code>qc_output.draw()<jupyter_output><empty_output><jupyter_text>Execute Qubits are always initialized to give the output 0. We do not have anything in out qubits in the circuit above.We can see this by running the circuit many times and plotting the results in a histogram. Here, we will use the following routines:- QasmSimulator: We use an Aer simulator. More info about [Aer](https://medium.com/qiskit/qiskit-aer-d09d0fac7759)- plot_histogram: This routine plots histogramExamples with different [Aer backend](https://qiskit.org/documentation/tutorials/circuits/1_getting_started_with_qiskit.html:~:text=A%20basic%20workflow%20using%20Qiskit,run%20them%20on%20different%20backends.)<jupyter_code>from qiskit.providers.aer import QasmSimulator
# Use Aer's qasmSimulator
simulator = QasmSimulator()
# Execute the circuit on the qasm simulator
job = simulator.run(qc_output, shots=1000)

# Grab results from the job
result = job.result()
# See what the result contains
result
# Returns counts
counts = result.get_counts(qc_output)<jupyter_output><empty_output><jupyter_text>Visualize  We can visualize using plot_histogram().You can find more visualization routines [here](https://qiskit.org/documentation/apidoc/visualization.html)<jupyter_code>from qiskit.visualization import plot_histogram
plot_histogram(counts)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07435376125471972, 'fraction_numerical': 0.010165553296543712, 'mean_word_length': 6.115702479338843, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 5, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '361374', 'license': 'MIT', 'n_tokens_mistral': 1058, 'n_tokens_neox': 964, 'n_words': 377, 'path': 'tutorials/notebooks/Getting started with Qiskit.ipynb', 'repo_name': 'sakira/QML', 'size': '3443'}