Division of Point in Elliptic Curve: Getting Back Point Let $P=(x_p,y_p)$ be a point on elliptic curve $E (a, b) := y^2=x^3+ax+b$, for an integer $n$, there exists a point $Q=(x_q,y_q)=nP$ on $E (a, b)$.

If $(x_q,y_q)$ and $n$ are given, what is the algorithm to find  $(x_p,y_p)$?

If possible provide code for python.
With Elliptic Curves, we can compute the order of any point (and, in particular, the point $nP$; this is especially easy on the curves we actually use for ECC, because those curves typically have an order $hq$, for a small $h$ and a large prime $q$ (and the order of any point is a divisor of $hq$).

So, if $q$ is the order of the point $nP$, and if $n$ is relatively prime to $q$ (since we generally have $q$ prime in practice), we just compute $n^{-1} \bmod q$; we then have $(n^{-1} \bmod q)nP = P$; that is, multiplying $nP$ by the scalar $n^{-1} \bmod q$ gives us back the original point.