# Write a Python program that inputs three numbers and calculates two sums as per this: Sum 1 as the sum of all numbers. Sum 2 as the sum of non-duplicate numbers, if there are duplicates, then ignore them.

Hello readers in this article I will show you how to write a Python program that inputs three numbers and calculates two sums as per this: Sum 1 as the sum of all numbers. Sum 2 as the sum of non-duplicate numbers, if there are duplicates, then ignore them.

``````n=int(input("enter any number"))
n1=n
s=0
while(n!=0):
r=n%10
q=n//10
n=q
s+=r
print("Sum1=",s)

#sum2
rn=n1%10
qn=n1//10
n1=qn
r1=qn%10
q1=qn//10
if (rn == r1 and r1 == q1):
print("Sum2= 0")
elif (rn==q1):
print("Sum2=",r1)
elif(r1==q1):
print("Sum2=",rn)
elif(r1==rn):
print("Sum2=",q1)
else:
print("Sum2=",s)``````

Output

``````enter any number533
Sum1= 11
Sum2= 5``````

As you can see with this you can write a Python program that inputs three numbers and calculates two sums as per this: Sum 1 as the sum of all numbers. Sum 2 as the sum of non-duplicate numbers, if there are duplicates, then ignore them.

Thank you.