Add a number to a number to be prime number in python
To be cheeky, the ultimate optimization is &quot;don't use Python for numerics&quot;, and the next-best optimization is &quot;use a library rather than writing this yourself&quot;.
It's worth having a read through https://stackoverflow.com/questions/4114167/checking-if-a-number-is-a-prime-number-in-python
Also consider calling into https://docs.sympy.org/latest/modules/ntheory.html#sympy.ntheory.primetest.isprime .
Otherwise:
Roots
I do not trust Python to do the right thing here:
b**(0.5)

Just call isqrt instead, which will be more likely to get an optimized implementation. This is confirmed here: https://stackoverflow.com/questions/327002/which-is-faster-in-python-x-5-or-math-sqrtx
Variable names
You need to get out of the habit of single-letter variable names. I have no idea what b means other than inferring based on context.
Time measurement
Use timeit. Your current implementation only has a single iteration for each of the input values and is thus extremely vulnerable to CPU thread-switching noise, etc.