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

沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...