# Error on trying to do the exercise PF 3.3

**URL:** <https://discuss.pennylane.ai/t/error-on-trying-to-do-the-exercise-pf-3-3/8736>\
**Category:** Codebook\
**Created:** [July 8, 2025, 12:52pm UTC](https://discuss.pennylane.ai/t/error-on-trying-to-do-the-exercise-pf-3-3/8736 "2025-07-08T12:52:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mickpires](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/mickpires/32/3897_2.png) [@mickpires](https://discuss.pennylane.ai/u/mickpires)\
**Post date:** [July 8, 2025, 12:52pm UTC](https://discuss.pennylane.ai/t/error-on-trying-to-do-the-exercise-pf-3-3/8736/1 "2025-07-08T12:52:26Z")

</div>

I had an error when trying to do the PF 3.3. The exercise asks: For the same Bell circuit as before, build a 2-qubit device and return the probabilities for the tensor observable \<Z\_1 tensor\_product z\_2\>. Don’t use shots, we’ll want the analytic value instead.

my attempt

```auto

dev = qml.device('default.qubit', wires = 2) # Define a two-qubit device here

@qml.qnode(dev)
def circuit():
    """
    This quantum function implements a Bell state and
    should return the probabilities for the PauliZ 
    observable on both qubits, using a single measurement
    """
    qml.H(wires=0)
    qml.CNOT(wires=[0,1])
    return qml.expval(qml.Z(wires = 0) @ qml.Z(wires = 1)) # Add your measurement here

print(circuit())

```

it returns 0.9999999999999998. I saw that it should return 1. It’s happening a round-off error here because it is saying that the measurement isn’t right.

---

<div class="post-metadata">

**Author:** ![daniela.murcillo](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/daniela.murcillo/32/3612_2.png) [@daniela.murcillo](https://discuss.pennylane.ai/u/daniela.murcillo)\
**Post date:** [July 8, 2025, 1:52pm UTC](https://discuss.pennylane.ai/t/error-on-trying-to-do-the-exercise-pf-3-3/8736/2 "2025-07-08T13:52:46Z")

</div>

Hi @mickpires, welcome to the forum!  
The question is asking you to return the _probabilities_ and you are returning the expectation value. It is not a rounding error, it is indeed the measurement being incorrect.  
See the table in the theory of that Codebook section, you have counts, sample, expectation value, probability.  
Let me know if this worked for you.

---

<div class="post-metadata">

**Author:** ![mickpires](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/mickpires/32/3897_2.png) [@mickpires](https://discuss.pennylane.ai/u/mickpires)\
**Post date:** [July 12, 2025, 12:01am UTC](https://discuss.pennylane.ai/t/error-on-trying-to-do-the-exercise-pf-3-3/8736/3 "2025-07-12T00:01:11Z")

</div>

Thanks. I didn’t pay attention hehe
