Ask Question
15 April, 09:09

Produce a list named primes which only contains the central number of two twin primes in the range [2,1000]. (A twin prime is a prime number which has another prime number two away from it, like 41 and 43; in this case, we would add the number 42 to our list.) We provide a function is_prime to assist you with this. Call it like this: is_prime (5).

+5
Answers (1)
  1. 15 April, 12:56
    0
    def is_prime (x):

    for i in range (2, x):

    if x%i==0:

    return False

    return True

    primes=[]

    for i in range (2,1001):

    # print (i, is_prime (i), is_prime (i+2))

    if is_prime (i) and is_prime (i+2):

    primes. append (i+1)

    print (primes)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Produce a list named primes which only contains the central number of two twin primes in the range [2,1000]. (A twin prime is a prime ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers