码迷,mamicode.com
首页 > 编程语言 > 详细

python 函数 练习

时间:2018-11-02 15:31:26      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:打印   class   style   rgs   div   ota   span   func   color   

# 2、写函数,接收n个数字,求这些参数数字的和。
def sum_func(*args):
    total = 0
    for i in args:
        total += i
    return total
print(sum_func(1,2,3,8,23,6))

# 3、读代码,回答:代码中,打印出来的值a,b,c分别是什么?为什么?
#     a=10
#     b=20
#     def test5(a,b):
#          print(a,b)
#     c = test5(b,a)
#     print(c)



# 4、读代码,回答:代码中,打印出来的值a,b,c分别是什么?为什么?
#     a=10
#     b=20
#     def test5(a,b):
#         a=3
#         b=5
#          print(a,b)
#     c = test5(b,a)
#     print(c)

 

python 函数 练习

标签:打印   class   style   rgs   div   ota   span   func   color   

原文地址:https://www.cnblogs.com/xiao-zhi/p/9896205.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!