+Z
|
|
|
- Q - - - - - O - - - - - + Q
|
|
|
-Z
VqZ ZqV
0
QzP PzQ
import QuantumCircuit, Aer, execute
# Create a quantum circuit with 1 qubit
qc = QuantumCircuit(1)
# Apply a Hadamard gate to create superposition
qc.h(0)
# Measure the qubit
qc.measure_all()
# Visualize the circuit
print(qc)
# Simulate the circuit
simulator = Aer.get_backend('qasm_simulator')
result = execute(qc, backend=simulator, shots=1024).result()
# Get the results
counts = result.get_counts(qc)
print(counts)