How to run multiple calculations at once using python? : <p>I have recently started using python and to try learn I have set a task of being able to run two chunks of code at once.
I have 1 chunk of code to generate and append prime numbers into a list</p>

<pre><code>primes=[]
for num in range(1,999999999999 + 1): 
    if num &gt; 1: 
        for i in range(2,num): 
            if (num % i) == 0: 
                break 
        else: 
            primes.append(num)
</code></pre>

<p>And another chunk of code to use the prime numbers generates to find perfect numbers</p>

<pre><code>limit = 25000000000000000000
for p in primes():
    pp = 2**p
    perfect = (pp - 1) * (pp // 2)
    if perfect &gt; limit:
        break
    elif is_prime(pp - 1):
        print(perfect)
</code></pre>

<p>I have heard of something to do with importing thread or something along those lines but I am very confused by it, if anyone can help by giving me clear instructions on what to do that would be very appreciated. I have only been learning python for about a week now. </p>

<p><em>Final note, I didn't code these calculations myself but I have modified them to what I need them for</em> </p>
