用Python写一个,两个数的加,减,乘,除的函数,然后用这些函数,完成简单的计算,怎么写

如题所述

我课程中的部分代码(除没写):


def f_add(a,b):
    return a+b
def f_mul(a,b):
    return a*b
def f_sub(a,b):
    return a-b
    
def g1(f,a,b):
    return f(a,b)

a,b,c,d = 1,2,3,4
print g1(f_sub, g1(f_mul, g1(f_add,a,b), c), d),  g1(f_mul, g1(f_add,a,b), g1(f_sub,c, d))


对python感兴趣可以到这里了解一下:

study.163.com/course/courseMain.htm?courseId=1000035

温馨提示:答案为网友推荐,仅供参考