> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rhymeq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# qint: Working with Quantum Integers

What if a variable could hold multiple values?

If you've used Python before, the syntax will look familiar:

```python theme={null}
x = 14
```

Here, `x` simply holds `14`.

In Rhyme, we can write:

```python theme={null}
from rhyme import qint

x = qint(14, 23)
```

The syntax is still familiar, but `x` now holds multiple values in superposition. Here, the value of `x` is a combination of `14` and `23`.

But what does that actually look like? Let's take a peek inside.

## What's inside a `qint`?

Each of the values `14` and `23` participates in the superposition with an amplitude. We can inspect their amplitudes:

![Rhyme debugger showing qint amplitudes](https://mintcdn.com/rhyme-q/JlURJlNdnA85HOaP/images/basic-tutorials/qint_superposition.png?fit=max\&auto=format\&n=JlURJlNdnA85HOaP\&q=85\&s=d5ab21ac29ff81e4d70fbffe94d2d9b9)

You can think of amplitudes as numbers that describe how the superposition is distributed across its participating values.

In this example, `14` and `23` both participate in the superposition with equal amplitudes:

$$
\frac{1}{\sqrt{2}} \approx 0.707
$$

So the superposition looks like:

$$
14 \rightarrow \frac{1}{\sqrt{2}} \approx 0.707
$$

$$
23 \rightarrow \frac{1}{\sqrt{2}} \approx 0.707
$$

But there is a problem: quantum mechanics does not allow us to directly see the amplitudes. If we want to get information from a superposition, we have to **observe** it.

## From a superposition to a value

Let's make this concrete.

Suppose `14` and `23` are two node IDs in a network, representing two possible next hops for a packet:

```python theme={null}
next_hop = qint(14, 23)
```

![Visual representation of the example](https://mintcdn.com/rhyme-q/JlURJlNdnA85HOaP/images/basic-tutorials/qint_example.png?fit=max\&auto=format\&n=JlURJlNdnA85HOaP\&q=85\&s=082080eac50d83c200cd6ae1243fd3ce)

Now let's observe it:

```python theme={null}
node = next_hop.observe()
```

`observe()` collapses the superposition to exactly one of the values that participate in it. Before observation, both values co-exist as possibilities.

![Rhyme debugger showing one value remaining after the collapse with amplitude of 1](https://mintcdn.com/rhyme-q/JlURJlNdnA85HOaP/images/basic-tutorials/qint_collapse.png?fit=max\&auto=format\&n=JlURJlNdnA85HOaP\&q=85\&s=786b4d984079bdc00eaa612dee3f2ec2)

Here, `23` is the observed value, with an amplitude of `1`, while the amplitude of `14` is now `0`.

![qint in superposition before observation and its collapse value after observation](https://mintcdn.com/rhyme-q/JlURJlNdnA85HOaP/images/basic-tutorials/qint_before_and_after.png?fit=max\&auto=format\&n=JlURJlNdnA85HOaP\&q=85\&s=ffa12096609ed4e080fc149fc10933fa)

So what determines which value we observe? **The amplitude tells us.**

The squared magnitude of an amplitude gives the probability of observing that value. In our example:

$$
14 \rightarrow \left|\frac{1}{\sqrt{2}}\right|^2 = 0.5
$$

$$
23 \rightarrow \left|\frac{1}{\sqrt{2}}\right|^2 = 0.5
$$

So `14` and `23` have equal probabilities of being observed: 50% each.

For this example, the observed value can be either `14` or `23`. Since the two values have equal amplitudes, repeated runs produce the two values with equal probabilities.

## More than two values

A `qint` can also represent several values at once.

For example:

```python theme={null}
x = qint(2, 7, 31, 42)
```

Here, all four values participate in the superposition with equal amplitudes.

![Rhyme debugger showing equal amplitudes of all four values](https://mintcdn.com/rhyme-q/JlURJlNdnA85HOaP/images/basic-tutorials/qint_multiple_values.png?fit=max\&auto=format\&n=JlURJlNdnA85HOaP\&q=85\&s=4ca7b2e988196584f6052e5068a294dd)

That's the basic idea behind superposition: *a value can be a combination of multiple values, each with its own amplitude.*

That's it.

You've just created a quantum integer, inspected the amplitudes of its values, and observed the result.

`qint` creates a value in superposition.
`observe()` collapses the superposition to one of its participating values.

**And that's your first step into Rhyme!!**


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.