python教程6 传递参数函数

#!/usr/bin/python
# -*- coding: UTF-8 -*-
 
#可写函数说明
def printinfo(kname, age ):
   "打印任何传入的字符串"
   print ("Name: ", kname)
   print ("Age ", age)
   return
 
#调用printinfo函数
printinfo(age=50, kname="miki" )

  

#!/usr/bin/python
# -*- coding: UTF-8 -*-
 
#可写函数说明
def printinfo(kname, age ):
   "打印任何传入的字符串"
   print ("Name: ", kname)
   print ("Age ", age)
   return
 
#调用printinfo函数
printinfo(age=50, kname="miki" )

#!/usr/bin/python
# -*- coding: UTF-8 -*-
 
# 可写函数说明
sum = lambda arg1, arg2: arg1 + arg2
 
# 调用sum函数
print ("相加后的值为 : ", sum( 10, 20 ))
print ("相加后的值为 : ", sum( 20, 20 ))

  

posted @ 2024-03-27 16:43  飞雪飘鸿  阅读(6)  评论(0编辑  收藏  举报
https://damo.alibaba.com/ https://tianchi.aliyun.com/course?spm=5176.21206777.J_3941670930.5.87dc17c9BZNvLL