Create a user defined function isPrime() to accept a number and returns True if number is prime otherwise False. (A number is said to be prime if it is only…

ICSE Class 10 Robotics & AI PYQ · 2025 Specimen · Section B

4(iii)Written · 2025 · Section B · 2025 Specimen

Create a user defined function isPrime() to accept a number and returns True if number is prime otherwise False. (A number is said to be prime if it is only divisible by itself and 1)

Show SolutionHide Solution↓
def isPrime(n):
    if n <= 1:
        return False
    for i in range(2, n):
        if n % i == 0:
            return False
    return True
← Previous questionNext question →

Browse the free Robotics & AI sample bank