Answer to Question #264548 in Python for swsq

Question #264548

A python program to print Sum of all prime and non prime numbers in a given range


1
Expert's answer
2021-11-22T09:55:05-0500
inp = int(input("Enter a positive integer number: "))




is_primes = []  # list of potential prime numbers(contains primes and non primes)




for counting in range(inp):
    read = int(input("> "))
    is_primes.append(read)




non_primes = []




for number in is_primes:




    if number == 2 or number == 3:
        pass
    else:
        for i in range(2, number):
            if number % i == 0:
                non_primes.append(number)
                break
            else:
                pass




            
print(sum(non_primes))

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