It uses SageMath. Replace ".nbits()" with ".bit_length()" for normal Python (documentation says nbits is an alias:
https://doc.sagemath.org/html/en/reference/rings_standard/sa... ).
You'll also need to remove the IPython import if not using a notebook.
Curiously, the listed output includes:
First 5 primes found and last five primes found [2, 3, 11, 13, 17]
... [4194295, 4194299, 4194301, 4194305, 4194307]
5 and 7 are not on that list. And 4194295 = 5 * 7 * 293 * 409 is not prime, and 4194299 = 29 * 61 * 2371 is also not prime. And 4194305 is clearly not prime either.
How is this supposed to be a prime sieve?