pip install qiskit

pip install qiskit-ibm-runtime

!pip install pylatexenc

!pip install matplotlib

!pip install matplotlib-venn

import qiskit
from qiskit import QuantumCircuit,QuantumRegister,ClassicalRegister,execute,IBMQ,  assemble, Aer
from qiskit.visualization import plot_histogram, plot_bloch_vector
from math import sqrt, pi

#qc = QuantumCircuit(1) # Create a quantum circuit with one qubit

qc = QuantumCircuit(1)  # Create a quantum circuit with one qubit
initial_state = [0,1]   # Define initial_state as |1>
qc.initialize(initial_state, 0) # Apply initialisation operation to the 0th qubit
qc.draw()  # Let's view our circuit

qc = QuantumCircuit(3,3)  # Create a quantum circuit with 3 qubits, like in python
qc.h(0) #hadamard gate
qc.x(1) #Pauli-X gate
qc.y(2) #Pauli-Y gate
qc.draw()  # Let's view our circuit

qc = QuantumCircuit(3,3)  # Create a quantum circuit with 3 qubits, like in python
qc.h(0) #hadamard gate
qc.x(1) #Pauli-X gate
qc.y(2) #Pauli-Y gate
qc.measure_all()
# Let's view our circuit
qc.draw('mpl')

import qiskit
from qiskit import QuantumCircuit,QuantumRegister,ClassicalRegister,execute,IBMQ,  assemble, Aer
from qiskit.visualization import plot_histogram, plot_bloch_vector
from math import sqrt, pi

X = QuantumRegister(1, "Alice") #naming the qubit
#naming the qubit
circuit = QuantumCircuit(X)
circuit.h(X)
circuit.s(X)
circuit.h(X)
circuit.t(X)
circuit.draw('mpl')

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister

X = QuantumRegister(1, "x")
Y = QuantumRegister(1, "y")
A = ClassicalRegister(1, "a")
B = ClassicalRegister(1, "b")

circuit = QuantumCircuit(Y, X, B, A)
circuit.h(Y)
circuit.cx(Y, X)
circuit.measure(Y, B)
circuit.measure(X, A)

display(circuit.draw('mpl'))

qc = QuantumCircuit(4)
qc.x(0)
qc.y(1) # Qubit number inside the bracket, as in python the counting starts from 0
qc.z(2)
qc.barrier
qc.y(0)
qc.z(0)
qc.draw('mpl')

bell = QuantumCircuit(2)

bell.h(0) # apply an H gate to the circuit
bell.cx(0,1) # apply a CNOT gate to the circuit

bell.draw(output="mpl")

import numpy as np

# Importing standard Qiskit libraries
from qiskit import QuantumCircuit, transpile, assemble, Aer, IBMQ, execute
from qiskit.quantum_info import Statevector
from qiskit.visualization import plot_bloch_multivector, plot_histogram

def bitflip():
    qc = QuantumCircuit(1)
    qc.x(0)
    return qc

state = Statevector.from_instruction(bitflip())
plot_bloch_multivector(state)

def superposition():
    qc = QuantumCircuit(1)
    qc.h(0)
    return qc

state = Statevector.from_instruction(superposition())
plot_bloch_multivector(state)

def antisuperposition():
    qc = QuantumCircuit(1)
    qc.h(0)
    qc.z(0) #phase flip
    return qc

state = Statevector.from_instruction(antisuperposition())
plot_bloch_multivector(state)

def complex():
    qc = QuantumCircuit(1)
    qc.h(0)
    qc.sdg(0)
    return qc

state = Statevector.from_instruction(complex())
plot_bloch_multivector(state)

