from qiskit import *

q = QuantumRegister(2,"q")
c = ClassicalRegister(2,"c")
qc = QuantumCircuit(q,c)

qc.x(q[0])

qc.measure(q[0],c[0])

qc.h(q[1]).c_if(c,0)

qc.measure(q,c)

print(qc)

job = execute(qc,Aer.get_backend('qasm_simulator'),shots=1024)
counts = job.result().get_counts(qc)
print(counts) # counts is a dictionary

q2 = QuantumRegister(2,"qreg")
c2 = ClassicalRegister(2,"creg")
qc2 = QuantumCircuit(q2,c2)


qc2.x(q2[1])
qc2.z(q2[1])

qc2.measure(q2,c2)
job = execute(qc2,Aer.get_backend('qasm_simulator'),shots=100)
counts = job.result().get_counts(qc2)
print(counts) # counts is a dictionary

from math import pi

q =  QuantumRegister(1) # quantum register with a single qubit
c = ClassicalRegister(1) # classical register with a single bit
qc = QuantumCircuit(q,c) # quantum circuit with quantum and classical registers

# rotate the qubit with rotation_angle
qc.ry(2*(pi/3),q[0])

# measure the qubit
qc.measure(q,c)
job = execute(qc,Aer.get_backend('qasm_simulator'),shots=1000)
counts = job.result().get_counts(qc)
print(counts) # counts is a dictionary

q2 = QuantumRegister(1,"qreg")
c2 = ClassicalRegister(1,"creg")
qc2 = QuantumCircuit(q2,c2)

#Your code here1
qc2.x(q2[0])
#Your code here2
qc2.h(q2[0])
qc2.measure(q2,c2)
job = execute(qc2,Aer.get_backend('qasm_simulator'),shots=100)
counts = job.result().get_counts(qc2)
print(counts) # counts is a dictionary

