📜  如何在 Python 中以数学方式交换数字 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:21.028000             🧑  作者: Mango

代码示例1
def swap_by_temp_var(num1,num2):
    temp = num1
    num1 = num2
    num2 = temp
    return num1, num2
def swap_by_mathamatically(num1,num2):
    num1 = num1 + num2
    num2 = num1-num2
    num1 = num1-num2
    return num1, num2
print(swap_by_temp_var(100,80))
print(swap_by_mathamatically(100,80))