Ask Question
2 January, 09:29

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

+1
Answers (1)
  1. 2 January, 12:47
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers