fibo and prime series3

import math

num = int(input())


def isPrime(num):
    if num == 2 or num == 3 or num == 5 or num == 7:
        prime = True
    elif num % 2 == 0 or num % 3 == 0 or num % 5 == 0 or num % 7 == 0:
        prime = False
    elif math.ceil(math.sqrt(num)) - math.floor(math.sqrt(num)) == 0:
        prime = False
    else:
        prime = True
    return prime


prime = []
for i in range(2, num * 2):
    if isPrime(i):
        prime.append(i)

fibo = [0, 1]
for i in range(2, (num // 2) + 1):
    fibo.append(fibo[-1] + fibo[-2])
fibo.remove(0)


prime = prime[:num//2]


def merge_lists(list1, list2):
    list3 = []
    while True:
        try:
            list3.append(list1.pop(0))
            list3.append(list2.pop(0))
        except IndexError:
            break
    return list3

print(merge_lists(fibo, prime))

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source