CS103 Spring 2020Homework 4Page 4of 4notPrimes (t)Write the function notPrimes(t)that takes a tuple tand returns a list which includes all of the numbers which are not a prime number.Assume the tuple only includes positive integers

Respuesta :

Answer:

Below is the required code with output.

Explanation:

def notPrimes(t):

   result = []

   for x in t:

       for i in range(2,x):

           if(x%i == 0):

               result.append(x)

               break

   return result

#Testing

print(notPrimes((3, 4, 5)))

print(notPrimes((3, 4, 5, 6, 12, 14, 21)))

print(notPrimes((12,17,11,22,24)))

Output:

[4]

[4, 6, 12, 14, 21]

[12, 22, 24]

ACCESS MORE