首页 > 编程语言 > 详细

Python中函数Function知识点

时间:2018-10-05 11:42:05      阅读:153      评论:0      收藏:0      [点我收藏+]

In general, you can tell whether something is callable or not with the built-in function callable.

技术分享图片
1 import math
2 
3 x=1
4 y=fibs_compute
5 print(callable(x))
6 print(callable(y))
View Code

 

定义函数,求斐波那契数列

技术分享图片
 1 import math
 2 
 3 def fibs_compute(number):
 4     fibs=[0,1]
 5     for i in range(int(number)-2):
 6         fibs.append(fibs[-1]+fibs[-2])
 7     return(fibs)
 8     
 9 num=input("How many numbers do you want?")
10 print("Here is:",fibs_compute(num))    
11    
View Code

 

The variables you write after your function name in def statements are often called the formal parameters of the function. 

The values you supply when you call the function are called the actual parameters, or arguments.

Python中函数Function知识点

原文:https://www.cnblogs.com/wintersweet321/p/9737395.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!