Python: Sum of three given integers. However, if two values are equal sum will be zero
Python Basic: Exercise-33 with Solution
Write a Python program to sum of three given integers. However, if two values are equal sum will be zero.
Sample Solution:-
def sum(x, y, z):
if x == y or y == z or x==z:
sum = 0
else:
sum = x + y + z
return sum
print(sum(12, 11, 12))
print(sum(3, 12, 12))
print(sum(12, 22, 22))
print(sum(11, 12, 13))
============ RESTART: F:/Python_APSC/py-ex-basic-33.py ===========
0
0
0
36
>>>
沒有留言:
張貼留言