Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: Implement a function to check if a number is prime.
Answer:

def is_prime(num):

  if num < 2:

  return False

  for i in range(2, int(num**0.5) + 1):

    if num % i == 0:

      return False

   return True

Example:

is_prime(11)  # Output: True
Is it helpful? Yes No

Most helpful rated by users:

©2025 WithoutBook