File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- from qiskit import QuantumCircuit , Aer , execute
2- from qiskit .visualization import plot_histogram
3- import math
1+ from qiskit import QuantumCircuit , transpile
2+ from qiskit_aer import AerSimulator
43
54# Number of qubits
6- n = 2
5+ n = int ( input ( "Enter the number of qubits: " ))
76
8- # Create Quantum Circuit
7+ # Create Quantum Circuit with classical bits
98qc = QuantumCircuit (n , n )
109
1110# Step 1: Initialize in superposition
2726qc .measure (range (n ), range (n ))
2827
2928# Run on simulator
30- backend = Aer .get_backend ('qasm_simulator' )
31- result = execute (qc , backend , shots = 1024 ).result ()
29+ backend = AerSimulator ()
30+ compiled_circuit = transpile (qc , backend )
31+ result = backend .run (compiled_circuit , shots = 1024 ).result ()
3232counts = result .get_counts ()
3333
3434print ("Measurement Result:" , counts )
You can’t perform that action at this time.
0 commit comments