function python怎么用

338次阅读
没有评论

function

在Jupyter notebook里面新建一个python文件。

function

简单地定义一个FUNCTION函数。

def function1():
    print("this is function1")
    print("function1 is here")
print("out of the function1")

然后调试function1()就可以看到该函数里面的内容。

this is function1
function1 is here

定义FUNCTION函数后,可以不断重复使用。

function

FUNCTION括号里面还可以增加数字。

def function2(x):
    return 2*x
hoo = function2(8)
print(hoo)

结果如下:

16

FUNCTION括号里面可以存在两个数字。

def function4(x, y):
    return x - y
woo = function4(8, 5)
print(woo)

结果如下:

3

FUNCTION函数可以同时定义PRINT和括号里的值。

def function5(x):
    print(x)
    print("this is function5")
    return 2*x
tooooo = function5(8)
print(tooooo)

结果如下:

16
神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:wuyou2021-06-26发表,共计562字。
新手QQ群:570568346,欢迎进群讨论 Python51学习