Here, This part is actually wrong:
for j in range(2, int(num**0.5)+1):
if num%j != 0:
sum1 = sum1 + num
you are adding num for each number in the range that didn't partition. you should sum just if every one of them didn't separate(divide).
Just simply try:
prime = True
for j in range(2, int(num**0.5)+1):
if num%j == 0:
prime = False
break
if prime:
sum1 = sum1 + num
Or try using all():
if all(num%j != 0 for j in range(2, int(num**0.5)+1)):
sum1 = sum1 + num
Wanna become a Python expert? Come and join the python certification course and get certified.
Watch this video tutorial for more information