Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please use python to solve this question Define a function is_prime that receive

ID: 3752687 • Letter: P

Question

please use python to solve this question

Define a function is_prime that receives an integer argument and returns true if the argument is a prime number and otherwise returns false. (An integer is prime if it is greater than 1 and cannot be divided evenly [with no remainder] other than by itself and one. For example, 15 is not prime because it can be divided by 3 or 5 with no remainder. 13 is prime because only 1 and 13 divide it with no remainder.) This function may be written with a for loop, a while loop or using recursion.

Explanation / Answer

def is_prime(x): #x is the variable input. is_prime is the function
if x > 1:  
for i in range(2,x): #for loop
if (x % i) == 0:  
return False #return for non-prime
break  
else:  
return True #return for prime
break
else:  
return False #return for non-prime

num = int(input("Enter a number: ")) #getting number in input
print(is_prime(num)) # calling is_prime function and printing return value