1 minute to read - Apr 12, 2023

Write code documentation in style of poem

Write a python code that prints out the first 100 primes and add a comment at the beginning where the code is described as a poem.

""" Primes so fine and rare, Here are the first hundred, With a loop so fair, They are all now thronged. """

def find\_primes(n): primes = \[\] for num in range(2, n+1): for i in range(2, num): if num % i == 0: break else: primes.append(num) return primes

print(find\_primes(100))

loading...