import qiskit
from qiskit import *
print(qiskit.__version__)
%matplotlib inline
from qiskit.tools.visualization import plot_histogram
from qiskit.providers.aer import QasmSimulator

# use Aer's qasm_simulator
simulator = QasmSimulator()

# create quantum circute acting on the q register
circuit = QuantumCircuit(2,2)

# add a H gate on qubit 0
circuit.h(0)

# add a cx (CNOT) gate on control qubit 0 and target qubit 1
circuit.cx(0,1)

# map the quantum measurement to the classical bits
circuit.measure([0,1],[0,1])

# compile the circuit down to low-level QASM instructions
# supported by the backend (not needed for simple circuits)
compiled_circuit = transpile(circuit, simulator)

# execute the circuit on the qasm simulator
job = simulator.run(compiled_circuit, shots=1024)

# grad results from the job
result = job.result()

# return counts
counts = result.get_counts(compiled_circuit)
print('total count for 00 and 11 are: ',counts)

# draw circuit
circuit.draw(output='mpl')

# plot histogram
plot_histogram(counts)

from qiskit.circuit import QuantumCircuit, Parameter
from qiskit.providers.aer import AerSimulator

backend = AerSimulator()
circuit = QuantumCircuit(2)
theta = Parameter('theta')
circuit.rx(234, 0)
circuit.draw(output='mpl')

backend = AerSimulator()
circuit = QuantumCircuit(2)
# theta = Parameter('theta')
circuit.rx(20, 0)
circuit.x(0)
circuit.h(1)
result = execute(circuit, backend=backend, shots=1024).result()
# counts=result.get_counts()
# print(counts)
circuit.draw(output='mpl')



