Answer to Question #205301 in Python for Jeevansai Gandham

Question #205301

For example, if the given number is 5, then read the inputs in the next 5 lines and print the sum of non-primes in the given five numbers. If the given input integers in the next five lines are 8, 11, 96, 49, and 25 the output should be 8 + 96 + 49 + 25 is 178.


1
Expert's answer
2021-06-10T03:36:23-0400
n = int(input())
numbers = []


for i in range(n):
    number = int(input())
    isPrime=True
    if number > 1:
        #Check if number if prime
        for j in range(2, number):
            if (number % j) == 0:
                isPrime=False
                break
        if isPrime==False:
            numbers.append(number)
                
print(sum(numbers))





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS