Ask Question

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

+2
Answers (1)
  1. 12 December, 03:01
    0
    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]
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “CS103 Spring 2020Homework 4Page 4of 4notPrimes (t) Write the function notPrimes (t) that takes a tuple tand returns a list which includes ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers