def add_num(a, b, f=abs): return f(a) + f(b) res = add_num(-7.2,5) # 12.2 res = add_num(2.8,5.1,round) # 8 print(res)
f 默认 abs 函数名,也可以用 round 函数名