函数与函数式编程

函数是逻辑结构化和过程化的一种编程方法

三种编程方式:

面向对象:>>>类>>>class

面向过程:>>>过程>>>def

函数式编程:>>>函数>>>def

 

 

#-*- coding:utf-8 -*-
__Author__ = "Devin"
def text(x):
    "The function definitions"
    x +=1
    return x

#def:关键字
#text:函数名
#():可定义参数
#"":文档描述
#x += 1:代码块
#return:返回值

 

 

#-*- coding:utf-8 -*-
__Author__ = "Devin"
#函数
def func1():
    "testing1"
    print("testing func1")
    return 0
#过程
def func2():
    "testing2"
    print("testing func2")

x = func1() #testing func1
y = func2() #testing func2

print('The func1 return is {}'.format(x)) #The func2 return is 0
print('The func2 return is {}'.format(y)) #The func2 return is None

 

posted @ 2020-04-22 13:35  汝南  阅读(104)  评论(0)    收藏  举报