Ask Question
26 July, 11: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

+5
Answers (1)
  1. 26 July, 12:09
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers