python:函数可以返回值--编写脚本计算24 + 34 / 100

1、脚本

def add(a,b):
    return (a+b)
def div(a,b,c):
    return (a/b-c)
x = div(34,100,1023)
y = add(24,x)
print ("the result is %f" %y)

print ("the result is %d" %y)

2、执行结果

备注

1、利用return可以将函数的值返回

2、%f返回浮点型

3、%d返回整形

原文地址:https://www.cnblogs.com/merry-0131/p/8466180.html