Consider the following quantum circuit

You want to take a single sample from both qubits, in the computational basis. You will need to create an instance of a device, and add a measurement to the circuit function that represents this quantum circuit. Note that you should only use a single measurement for both qubits (as opposed to one measurement per qubit).

dev = # Define a two-qubit device here

@qml.qnode(dev)
def circuit():
"""
This quantum function implements the circuit shown above
and should return a sample from all qubits
"""

qml.H(wires=0)
qml.CNOT(wires=[0,1])

return # Add your measurement here


or to submit your code

To interact with codercises, please switch to a larger screen size.

Learning Objectives:

  • Learn how to use different measurements in PennyLane.
  • Understand the role of observables in measurements.