# Introduction to Quantum Computing with Python and Qiskit

## First steps into the realm of quantum computing

Oct 16 · 6 min read

# Getting started with the Qiskit Library

`!pip install qiskit!pip install matplotlib`
`from qiskit import QuantumRegister,ClassicalRegister,Aer,executeimport Our_Qiskit_Functions as oq`
`# Initializing backend simulators to visualize circuitsS_simulator = Aer.backends(name='statevector_simulator')[0]Q_simulator = Aer.backends(name='qasm_simulator')[0]# Creating quantum registers to hold quibitsq = QuantumRegister(2)# Creating classical registers to hold bitsc = ClassicalRegister(2)# Create a quantum circuit with these registersqc=quantumCircuit(q,c)`

# Understanding Quantum Gates

`# Identity Gateqc.iden(q[0])print(oq.Wavefunction(qc))qc.draw(output = “mpl”)`
`# NOT gateqc.x(q[0])print(oq.Wavefunction(qc))qc.draw(output = "mpl")`
`# Controlled-NOT gateqc.cx(q[0],q[1])print(oq.Wavefunction(qc))qc.draw(output = "mpl")`

# Our First Quantum Circuit

`# Create the circuit and add the gatesq = QuantumRegister(5)c = ClassicalRegister(4)qc = QuantumCircuit(q,c)qc.x(q[0])qc.x(q[2])qc.x(q[3])qc.cx(q[3],q[4])qc.cx(q[4],q[3])qc.draw(output = "mpl")`
`# Execute the circuitex = execute(qc, Q_simulator, shots = 1024)res = ex.result()M = res.get_counts(qc)# Plot the resultsplot_histogram(M, bar_labels=False)`

## Towards AI

### By Towards AI

Towards AI publishes the best of tech, science, and engineering. Subscribe with us to receive our newsletter right on your inbox. For sponsorship opportunities, please email us at pub@towardsai.net Take a look

Written by

Written by