I'm trying to understand the Quantum Phase Estimation in the qiskit textbook https://qiskit.org/textbook/ch-algorithms/quantum-phase-estimation.html.
I know QPE is used to estimate the $\theta$ given the operator $U$ in $U|\psi\rangle = e^{2 \pi i \theta} |\psi\rangle$, but when I see the code for the problem in the same link further below, the theta is passed as input to the creation of the Controlled U gates (the variable 'angle' in the code snippet in the below link).
https://qiskit.org/textbook/ch-algorithms/quantum-phase-estimation.html#3.1-The-Problem-
We are trying to estimate the angle theta but then again we are passing the same as an input to the code. Isn't this cheating? What am I misunderstanding?
In the example, we know what the $\theta$ is but in the real world scenarios, will we not have only $\psi$ and no knowledge of $\theta$? How will it work? Please help me understand.