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

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返回整形

 

posted @ 2018-02-24 15:52  Tang豆豆  阅读(137)  评论(0编辑  收藏  举报