# Codebook

**URL:** https://discuss.pennylane.ai/c/codebook/17.md

[Latest](https://discuss.pennylane.ai/latest.md) · [Categories](https://discuss.pennylane.ai/categories.md)

---

## [About the Codebook category](https://discuss.pennylane.ai/t/about-the-codebook-category/1482)

<div class="topic-metadata">

**Author:** [@glassnotes](https://discuss.pennylane.ai/u/glassnotes)\
**Replies:** 0\
**Last updated:** [November 16, 2021, 2:25pm UTC](https://discuss.pennylane.ai/t/about-the-codebook-category/1482 "2021-11-16T14:25:49Z")

</div>

Use this category for questions about the content of the PennyLane Codebook!

---

## [Hint for PF 5.1 and 5.2](https://discuss.pennylane.ai/t/hint-for-pf-5-1-and-5-2/9730)

<div class="topic-metadata">

**Author:** [@mack.attack](https://discuss.pennylane.ai/u/mack.attack)\
**Replies:** 0\
**Last updated:** [October 24, 2026, 5:55am UTC](https://discuss.pennylane.ai/t/hint-for-pf-5-1-and-5-2/9730 "2026-10-24T05:55:14Z")

</div>

I admit I got stuck on this codercise, especially concerning the errors. If you see an error simply described as 0, 00, 1, or on the lines, it means you have indexed the answer incorrectly. Also, "00" is not equivalent …

---

## [\[HS.4.2a\] I have gotten the feedback "correct". But I think system answer is not correct](https://discuss.pennylane.ai/t/hs-4-2a-i-have-gotten-the-feedback-correct-but-i-think-system-answer-is-not-correct/9561)

<div class="topic-metadata">

**Author:** [@Ring](https://discuss.pennylane.ai/u/Ring)\
**Replies:** 0\
**Last updated:** [October 14, 2026, 2:40am UTC](https://discuss.pennylane.ai/t/hs-4-2a-i-have-gotten-the-feedback-correct-but-i-think-system-answer-is-not-correct/9561 "2026-10-14T02:40:05Z")

</div>

Hi, I have marked my answer and system’s “correct” answer in my code comments. Want to confirm if I’m right. #################### my code ################# h\_coeffs = \[1/4,1/4,1/2\] h\_ops = \[qp.PauliZ(5),qp.PauliZ(6)…

---

## [Purpose of qml variable definition on the code](https://discuss.pennylane.ai/t/purpose-of-qml-variable-definition-on-the-code/9420)

<div class="topic-metadata">

**Author:** [@mbzadegan](https://discuss.pennylane.ai/u/mbzadegan)\
**Replies:** 2\
**Last updated:** [October 11, 2026, 1:23am UTC](https://discuss.pennylane.ai/t/purpose-of-qml-variable-definition-on-the-code/9420 "2026-10-11T01:23:37Z")

</div>

Hello all, What is the reason for defining the qml variable in the following program on this page? Thank you :folded\_hands:

---

## ['QubitUnitary' object is not callable Error for codercise I.9.2](https://discuss.pennylane.ai/t/qubitunitary-object-is-not-callable-error-for-codercise-i-9-2/9505)

<div class="topic-metadata">

**Author:** [@AmruthA](https://discuss.pennylane.ai/u/AmruthA)\
**Replies:** 2\
**Last updated:** [October 10, 2026, 6:43pm UTC](https://discuss.pennylane.ai/t/qubitunitary-object-is-not-callable-error-for-codercise-i-9-2/9505 "2026-10-10T18:43:41Z")

</div>

In codercise I.9.2 in the Measurements Codebook challenge, I get Error: 'QubitUnitary' object is not callable when I run the correct code, or even when I run the provided starter code without any edits. Looks like the…

---

## [\[HS.4.2a\]Incorrect: Something is off with your Hamiltonian!](https://discuss.pennylane.ai/t/hs-4-2a-incorrect-something-is-off-with-your-hamiltonian/9497)

<div class="topic-metadata">

**Author:** [@Ring](https://discuss.pennylane.ai/u/Ring)\
**Replies:** 1\
**Last updated:** [September 11, 2026, 7:59pm UTC](https://discuss.pennylane.ai/t/hs-4-2a-incorrect-something-is-off-with-your-hamiltonian/9497 "2026-09-11T19:59:31Z")

</div>

Hi, When i coding HS.4.2a PrepSelPrep on the Walk operator, it show incorrect. error log\>\>\> Incorrect: Something is off with your Hamiltonian! my code\>\>\> offes = \[1/4,1/4,1/2\] objs = \[qml.Z(5),qml.Z(6),qml.Z(5)@qml…

---

## [Request for Missing Badges for Completed Codebook Modules](https://discuss.pennylane.ai/t/request-for-missing-badges-for-completed-codebook-modules/9464)

<div class="topic-metadata">

**Author:** [@Shah\_Hussain\_Pirzada](https://discuss.pennylane.ai/u/Shah_Hussain_Pirzada)\
**Replies:** 4\
**Last updated:** [August 19, 2026, 6:12pm UTC](https://discuss.pennylane.ai/t/request-for-missing-badges-for-completed-codebook-modules/9464 "2026-08-19T18:12:41Z")

</div>

Hi PennyLane Support Team, I have successfully completed 100% of the topics & challenges for the following modules in the PennyLane Codebook: 1: Hamiltonian Time Evolution 2: Noisy Quantum Theory All tasks show full …

---

## [Codexercise PF.4.1 (possible bug)](https://discuss.pennylane.ai/t/codexercise-pf-4-1-possible-bug/9428)

<div class="topic-metadata">

**Author:** [@Anton\_Naumov](https://discuss.pennylane.ai/u/Anton_Naumov)\
**Replies:** 3\
**Last updated:** [August 13, 2026, 4:06pm UTC](https://discuss.pennylane.ai/t/codexercise-pf-4-1-possible-bug/9428 "2026-08-13T16:06:59Z")

</div>

I have recently tried approaching codexercise PF.4.1 met a weird behavior. I tried this implementation: and got a “Correct” result. After that I commented out BasicEntanglerLayers and ran: and got a “Correct” result…

---

## [Codexercise I.13.5 possible bug](https://discuss.pennylane.ai/t/codexercise-i-13-5-possible-bug/9416)

<div class="topic-metadata">

**Author:** [@Anton\_Naumov](https://discuss.pennylane.ai/u/Anton_Naumov)\
**Replies:** 4\
**Last updated:** [August 13, 2026, 3:49pm UTC](https://discuss.pennylane.ai/t/codexercise-i-13-5-possible-bug/9416 "2026-08-13T15:49:53Z")

</div>

Hi, First of all, thank you for your excellent study materials and codexercises, they really thoughtful and engaging. My issue might be a duplicate of something, if so – sorry for that. Was recently solving Codexercise…

---

## [How to report some issues in the codebook](https://discuss.pennylane.ai/t/how-to-report-some-issues-in-the-codebook/9358)

<div class="topic-metadata">

**Author:** [@mbzadegan](https://discuss.pennylane.ai/u/mbzadegan)\
**Replies:** 9\
**Last updated:** [July 27, 2026, 1:45pm UTC](https://discuss.pennylane.ai/t/how-to-report-some-issues-in-the-codebook/9358 "2026-07-27T13:45:20Z")

</div>

Hi everybody, I found some issues in the codebook, but I cannot open a new issue in the GitHub repo because the repository has been archived. I also forked the codebook repository, but unfortunately, I’m unable to pull…

---

## [The codebook needs more basic explanation](https://discuss.pennylane.ai/t/the-codebook-needs-more-basic-explanation/9413)

<div class="topic-metadata">

**Author:** [@mbzadegan](https://discuss.pennylane.ai/u/mbzadegan)\
**Replies:** 3\
**Last updated:** [July 23, 2026, 9:21pm UTC](https://discuss.pennylane.ai/t/the-codebook-needs-more-basic-explanation/9413 "2026-07-23T21:21:13Z")

</div>

When I teach PennyLane to my students, they sometimes ask about basic concepts in the Codebook, such as where equation (7) comes from. I thought it would be helpful to provide the proof of equation (7) so that you can i…

---

## [Average time to complete one topic in each Pennylane Module](https://discuss.pennylane.ai/t/average-time-to-complete-one-topic-in-each-pennylane-module/9415)

<div class="topic-metadata">

**Author:** [@lugoblogger](https://discuss.pennylane.ai/u/lugoblogger)\
**Replies:** 1\
**Last updated:** [July 21, 2026, 1:48am UTC](https://discuss.pennylane.ai/t/average-time-to-complete-one-topic-in-each-pennylane-module/9415 "2026-07-21T01:48:27Z")

</div>

I wonder how long is to complete on average or normal phyiscs student for one topic in each Pennylane codebook module. For me, sometimes, it takes more than just 30 minutes or a couple of days to understand the concept …

---

## [HS.5.2 polynomial](https://discuss.pennylane.ai/t/hs-5-2-polynomial/9393)

<div class="topic-metadata">

**Author:** [@mchau](https://discuss.pennylane.ai/u/mchau)\
**Replies:** 2\
**Last updated:** [July 7, 2026, 4:20pm UTC](https://discuss.pennylane.ai/t/hs-5-2-polynomial/9393 "2026-07-07T16:20:55Z")

</div>

The exercise is from the link above. We need to use QSP to estimate the \\text{erf} function. I tried to solve that without viewing the hint by estimating the Chebyshev series of erf. I run this externally and copy the …

---

## [Stuck on HS.1.4](https://discuss.pennylane.ai/t/stuck-on-hs-1-4/9389)

<div class="topic-metadata">

**Author:** [@lemjm](https://discuss.pennylane.ai/u/lemjm)\
**Replies:** 1\
**Last updated:** [June 23, 2026, 10:28pm UTC](https://discuss.pennylane.ai/t/stuck-on-hs-1-4/9389 "2026-06-23T22:28:25Z")

</div>

Hi. I’m currently stuck on codercise HS.1.4. I think I understand the theory, but somehow can manage to get my code accepted. Can anyone help me ? Here are my attempts :

---

## ["typo" in codercise V1.1](https://discuss.pennylane.ai/t/typo-in-codercise-v1-1/9279)

<div class="topic-metadata">

**Author:** [@kasterma](https://discuss.pennylane.ai/u/kasterma)\
**Replies:** 2\
**Last updated:** [June 23, 2026, 8:29pm UTC](https://discuss.pennylane.ai/t/typo-in-codercise-v1-1/9279 "2026-06-23T20:29:09Z")

</div>

def basic\_entangling\_ansatz(observable,params): “”"Applies an ansatz with basic entanglement. Args: observable (qml.op): a pennylane operator whose expectation value we want to measure. params(np.ar…

---

## [QAOA Workflow: contradictory information](https://discuss.pennylane.ai/t/qaoa-workflow-contradictory-information/9350)

<div class="topic-metadata">

**Author:** [@fyellin](https://discuss.pennylane.ai/u/fyellin)\
**Replies:** 4\
**Last updated:** [June 22, 2026, 10:07pm UTC](https://discuss.pennylane.ai/t/qaoa-workflow-contradictory-information/9350 "2026-06-22T22:07:54Z")

</div>

I’m confused by two seemingly contradictory steps in the QAOA workflow. Define the mixer Hamiltonion. . . A common choice for H\_m is … \\sum{X\_j} Initialize the quantum system in the ground state of H\_m which is usuall…

---

## [The new PennyLane Codebook is here!](https://discuss.pennylane.ai/t/the-new-pennylane-codebook-is-here/4595)

<div class="topic-metadata">

**Author:** [@discourse-admin](https://discuss.pennylane.ai/u/discourse-admin)\
**Replies:** 2\
**Last updated:** [May 27, 2026, 12:23am UTC](https://discuss.pennylane.ai/t/the-new-pennylane-codebook-is-here/4595 "2026-05-27T00:23:33Z")

</div>

Meet the new Codebook! Learn quantum computing with PennyLane — the leading tool for programming quantum computers. Share your feedback about the new Codebook here!

---

## [What does "Error '00' mean?](https://discuss.pennylane.ai/t/what-does-error-00-mean/9347)

<div class="topic-metadata">

**Author:** [@fyellin](https://discuss.pennylane.ai/u/fyellin)\
**Replies:** 5\
**Last updated:** [May 25, 2026, 5:51pm UTC](https://discuss.pennylane.ai/t/what-does-error-00-mean/9347 "2026-05-25T17:51:54Z")

</div>

I’m running PF.5.1. My code runs. I get the printed output: the success probability is 0.2524 which is roughly what I expected but then above that I see a red stripe above my user output with the message Error '00'. …

---

## [Codebook: Variational Quantum Eigensolver](https://discuss.pennylane.ai/t/codebook-variational-quantum-eigensolver/7224)

<div class="topic-metadata">

**Author:** [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Replies:** 9\
**Last updated:** [May 19, 2026, 4:34pm UTC](https://discuss.pennylane.ai/t/codebook-variational-quantum-eigensolver/7224 "2026-05-19T16:34:43Z")

</div>

Ask here about the “Variational Quantum Eigensolver” Codebook topic from the “Introduction to Variational Quantum Algorithms” module.

---

## [Codercise G.5.1 - Preparing a multi-solution oracle](https://discuss.pennylane.ai/t/codercise-g-5-1-preparing-a-multi-solution-oracle/9335)

<div class="topic-metadata">

**Author:** [@delacroissant](https://discuss.pennylane.ai/u/delacroissant)\
**Replies:** 1\
**Last updated:** [May 13, 2026, 4:10pm UTC](https://discuss.pennylane.ai/t/codercise-g-5-1-preparing-a-multi-solution-oracle/9335 "2026-05-13T16:10:11Z")

</div>

In Codercise G.5.1 it is written: Let’s start by coding up this new oracle. Create an oracle for a random solution set of a given size using the MultiControlledX gate. Remember that this takes a string for control\_value…

---

## [Small typo in Codercise F.1.3 - The nearest power of 2](https://discuss.pennylane.ai/t/small-typo-in-codercise-f-1-3-the-nearest-power-of-2/9336)

<div class="topic-metadata">

**Author:** [@delacroissant](https://discuss.pennylane.ai/u/delacroissant)\
**Replies:** 2\
**Last updated:** [May 13, 2026, 7:23am UTC](https://discuss.pennylane.ai/t/small-typo-in-codercise-f-1-3-the-nearest-power-of-2/9336 "2026-05-13T07:23:37Z")

</div>

There is a small typo in the firsy hint in Codercise F.1.3. The text says: Let’s look at simple example, we want to find the nearest power of 2 of x = 16 (which is 16, of course). but instead it should say: “which i…

---

## [PF4.4 Differentiate and repear](https://discuss.pennylane.ai/t/pf4-4-differentiate-and-repear/9293)

<div class="topic-metadata">

**Author:** [@simpsoe](https://discuss.pennylane.ai/u/simpsoe)\
**Replies:** 1\
**Last updated:** [March 30, 2026, 8:29pm UTC](https://discuss.pennylane.ai/t/pf4-4-differentiate-and-repear/9293 "2026-03-30T20:29:08Z")

</div>

Having trouble with this and got stuck. Any help is appreciated. dev = qml.device("default.qubit", wires = 2) @qml.qnode(dev, diff\_method = "parameter-shift", max\_diff = 2) def circuit\_for\_hessian(params): """ Implemen…

---

## [PennyLane Fundamentals / Quantum Operations / ControlledQubitUnitary](https://discuss.pennylane.ai/t/pennylane-fundamentals-quantum-operations-controlledqubitunitary/9283)

<div class="topic-metadata">

**Author:** [@kasterma](https://discuss.pennylane.ai/u/kasterma)\
**Replies:** 1\
**Last updated:** [March 9, 2026, 9:25pm UTC](https://discuss.pennylane.ai/t/pennylane-fundamentals-quantum-operations-controlledqubitunitary/9283 "2026-03-09T21:25:08Z")

</div>

On page PennyLane Fundamentals | Quantum Operations | PennyLane Codebook the examples involving the ControlledQubitUnitary are incorrect. According to qml.ControlledQubitUnitary — PennyLane 0.44.0 documentation the inte…

---

## [Codercise V.1.4 - Training a model](https://discuss.pennylane.ai/t/codercise-v-1-4-training-a-model/7495)

<div class="topic-metadata">

**Author:** [@feynmannlu](https://discuss.pennylane.ai/u/feynmannlu)\
**Replies:** 6\
**Last updated:** [March 7, 2026, 7:58am UTC](https://discuss.pennylane.ai/t/codercise-v-1-4-training-a-model/7495 "2026-03-07T07:58:34Z")

</div>

I don’t understand what problem. Have someone also encounter the same problem?

---

## [Typos: H3 + I4 + \[min title len bonus\]](https://discuss.pennylane.ai/t/typos-h3-i4-min-title-len-bonus/9282)

<div class="topic-metadata">

**Author:** [@float2](https://discuss.pennylane.ai/u/float2)\
**Replies:** 1\
**Last updated:** [March 6, 2026, 4:04pm UTC](https://discuss.pennylane.ai/t/typos-h3-i4-min-title-len-bonus/9282 "2026-03-06T16:04:32Z")

</div>

Hi, I think I found a few typos, please review them. H3 / Theory / The quantum description: “…to replace S\_z it with…" H3 / Theory / Appendix - The Matrix Exponential: “We we need to…” H3 / Codercise H.3.1d: “So, we’…

---

## [Something went wrong. Please try submitting again later](https://discuss.pennylane.ai/t/something-went-wrong-please-try-submitting-again-later/7636)

<div class="topic-metadata">

**Author:** [@quantumel](https://discuss.pennylane.ai/u/quantumel)\
**Replies:** 7\
**Last updated:** [February 17, 2026, 10:39pm UTC](https://discuss.pennylane.ai/t/something-went-wrong-please-try-submitting-again-later/7636 "2026-02-17T22:39:15Z")

</div>

Hi, The Codercise V.3.3: Execution stucked “Something went wrong. Please try submitting again later.”

---

## [Codebook: Quantum Fourier Transform](https://discuss.pennylane.ai/t/codebook-quantum-fourier-transform/4980)

<div class="topic-metadata">

**Author:** [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Replies:** 14\
**Last updated:** [February 5, 2026, 6:26pm UTC](https://discuss.pennylane.ai/t/codebook-quantum-fourier-transform/4980 "2026-02-05T18:26:25Z")

</div>

Ask here about the “Quantum Fourier Transform” Codebook topic from the “Quantum Fourier Transform” module.

---

## [Seems to be old code in Codercise I.13.4](https://discuss.pennylane.ai/t/seems-to-be-old-code-in-codercise-i-13-4/8922)

<div class="topic-metadata">

**Author:** [@PranavUpreti](https://discuss.pennylane.ai/u/PranavUpreti)\
**Replies:** 3\
**Last updated:** [February 3, 2026, 3:53pm UTC](https://discuss.pennylane.ai/t/seems-to-be-old-code-in-codercise-i-13-4/8922 "2026-02-03T15:53:00Z")

</div>

Hi there! Hope you’re doing well. It seems like the explanation preceding Codercise I.13.4 may contain old code. It says to use 'qml.MultiControlledX(control\_wires=\[0, 1, 2\], wires=4, control\_values="001")\` but this g…

---

## [Returning Expectation Values Math Typo](https://discuss.pennylane.ai/t/returning-expectation-values-math-typo/9209)

<div class="topic-metadata">

**Author:** [@ambrose158](https://discuss.pennylane.ai/u/ambrose158)\
**Replies:** 1\
**Last updated:** [January 22, 2026, 8:54pm UTC](https://discuss.pennylane.ai/t/returning-expectation-values-math-typo/9209 "2026-01-22T20:54:46Z")

</div>

Seems to be a small typo in the mathematics for the “Returning Expection Values” challenge of Pennylane. The code is using a R\_y rotation but the definition looks like it’s using the Pauli X matrix.

---

## [Doubt in PF.2.1](https://discuss.pennylane.ai/t/doubt-in-pf-2-1/9203)

<div class="topic-metadata">

**Author:** [@swarad](https://discuss.pennylane.ai/u/swarad)\
**Replies:** 1\
**Last updated:** [January 19, 2026, 2:57pm UTC](https://discuss.pennylane.ai/t/doubt-in-pf-2-1/9203 "2026-01-19T14:57:24Z")

</div>

I am a newbie and i have been trying to debug this help will be appreciated

[Next page](https://discuss.pennylane.ai/c/codebook/17.md?page=1)
