2018年1月8日 星期一

Python: Sum of three given integers. However, if two values are equal sum will be zero

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
>>> 

沒有留言:

張貼留言

OPEN DATA AQI 空氣品質監測網 + NODE-RED

OPEN DATA AQI 空氣品質監測網 + NODE-RED  首頁 - 空氣品質監測網  https://airtw.moenv.gov.tw/ https://data.gov.tw/datasets/search?p=1&size=10&s=_score...