Add a number to a number to be prime number in python The program is to get the nearest prime number to a number while adding a number. I solved the problem but I wish to optimize the code.
import time
def isprime(a ,d):
    b=a
    c=0
    f=b**(0.5)
    for i in range(1,int(f)+1):
        if a%i==0 and c&lt;=1:
            c+=1
    if c==1:
        return d.append(b)
    else:
        b=a+1
        isprime(b,d)
 
start=time.time()        
b=[89, 54,36, 74, 44, 19, 12]   # Input
d=[]
for i in b:
    isprime(i,d)     #function call
print(d)             #output is [89, 59, 37, 79, 47, 19, 13]
stop=time.time()
print(stop-start)    #0.0001347064971923828 Seconds

Help with Code optimization. I'm just a beginner I know code is of lower. Help to learn bit of coding.
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.