# Codercise H.5.2 and Codercise H.5.3 code template typos

**URL:** <https://discuss.pennylane.ai/t/codercise-h-5-2-and-codercise-h-5-3-code-template-typos/7962>\
**Category:** Codebook\
**Created:** [February 4, 2025, 3:45pm UTC](https://discuss.pennylane.ai/t/codercise-h-5-2-and-codercise-h-5-3-code-template-typos/7962 "2025-02-04T15:45:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhanschoo](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/jhanschoo/32/2890_2.png) [@jhanschoo](https://discuss.pennylane.ai/u/jhanschoo)\
**Post date:** [February 4, 2025, 3:45pm UTC](https://discuss.pennylane.ai/t/codercise-h-5-2-and-codercise-h-5-3-code-template-typos/7962/1 "2025-02-04T15:45:16Z")

</div>

Hi, I noticed that the docstring in the code template contains an error; the template reads

```python
n_bits=2
dev = qml.device("default.qubit", wires=range(n_bits))

@qml.qnode(dev)
def two_close_spins_X(alpha, beta, time, n):
    """Circuit for evolving the state of two electrons with an X coupling.
    
    Args:
        beta (float): The strength of the field, assumed to point in the z direction.
        alpha (float): The strength of the coupling between electrons.
        time (float): The time we evolve the electron wavefunction for.
        n (int): The number of steps in our Trotterization.

    Returns: 
        array[complex]: The quantum state after evolution.
    """

    ##################
    # YOUR CODE HERE #
    ##################
    return qml.state()

```

when it should read something like:

```python
n_bits=2
dev = qml.device("default.qubit", wires=range(n_bits))

@qml.qnode(dev)
def two_close_spins_X(alpha, beta, time, n):
    """Circuit for evolving the state of two electrons with an X coupling.
    
    Args:
        alpha (float): The coefficient related to the strength of the field, assumed to point in the z direction.
        beta (float): The coefficient related to the strength of the coupling between electrons.
        time (float): The time we evolve the electron wavefunction for.
        n (int): The number of steps in our Trotterization.

    Returns: 
        array[complex]: The quantum state after evolution.
    """

    ##################
    # YOUR CODE HERE #
    ##################
    return qml.state()

```

the prose before this looks correct, and the solution expects the corrected description of input parameters as well.

Codercise H.5.3 has a typo in the docstring as well; the code template reads:

```auto
dev = qml.device("default.qubit", wires=range(n_bits))

def ham_close_spins(alpha, J):
    """Creates the Hamiltonian for two close spins.

    Args:
        B (float): The strength of the field, assumed to point in the z direction.
        J (list[float]): A vector of coupling [J_X, J_Y, J_Z].

    Returns:
        qml.Hamiltonian: The Hamiltonian of the system.
    """

    ##################
    # YOUR CODE HERE #
    ##################
    coeffs = [] # MODIFY THIS
    obs = [] # MODIFY THIS
    return # Return the Hamiltonian using qml.dot

```

it should read something like:

```auto
dev = qml.device("default.qubit", wires=range(n_bits))

def ham_close_spins(alpha, J):
    """Creates the Hamiltonian for two close spins.

    Args:
        alpha (float): The coefficient related to the strength of the field, assumed to point in the z direction.
        J (list[float]): A vector of coupling coefficients [J_X, J_Y, J_Z].

    Returns:
        qml.Hamiltonian: The Hamiltonian of the system.
    """

    ##################
    # YOUR CODE HERE #
    ##################
    coeffs = [] # MODIFY THIS
    obs = [] # MODIFY THIS
    return # Return the Hamiltonian using qml.dot

```

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [February 5, 2025, 8:52pm UTC](https://discuss.pennylane.ai/t/codercise-h-5-2-and-codercise-h-5-3-code-template-typos/7962/2 "2025-02-05T20:52:59Z")

</div>

Hi @jhanschoo good catches!

The fixes are done and should be in the Codebook today or tomorrow.

Thanks again for helping make the Codebook better! 🙌
