#!/usr/bin/python
#coding:utf8 #中文输入方式1
#coding=utf8 #中文输入方式2
#encoding:utf8 #中文输入方式3
#encoding=utf8 #中文输入方式4
#-*- coding:utf8 -*-#中文输入方式5
print '*'*35
print "实现输入两个变量的比较功能:"
def fun(x,y):# x,y 形参
if x == y:
print x, '=', y
else:
print x, '!=', y
x1 = raw_input("The first var:")
x2 = raw_input("The second var:")
fun(x1,x2)
print '*'*35
print '^'*35
print "冰淇淋制作机器!"
print "machine for ice cream:"
def machine(x=8,y='菠萝'):#x,y形参,设置默认初值
print "生成一个",x,'元,',y,'口味的冰淇淋!'
#s1 = raw_input("input something:")
#s2 = raw_input("input something:")
machine() #使用默认参量
machine(3) #只改变x参量
machine(y='奶油') #只改变y参量
machine(5,'巧克力') # s1,s2 shican
print '-'*35
print "machine1 for ice cream:"
def machine1(y,x=3):#默认参数从右至左
print "生成一个",x,'元,',y,'口味的甜点!'
machine1('奶油')
print "^"*35
print "Edited by tianzhaixing"
print "2013.11.28"
python函数形参和实参
原创
©著作权归作者所有:来自51CTO博客作者Digital2Slave的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:python--数据类型
下一篇:python return语句
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
【JavaScript】函数 ③ ( 形参 与 实参 匹配问题 | 实参个数 = 形参个数 | 实参个数 > 形参个数 | 实参个数 < 形参个数 )
一、JavaScript 函数 形参 与 实参 匹配问题1、函数形参与实参不匹配问题2、形参与实参个数匹配3、实参个数 > 形参个数4、实参个数 < 形参个数5、完整代码示例
javascript 开发语言 ecmascript 前端 JavaScript函数 -
实参和形参
形参:在方法声明上实参:实际参与运算的如果方法的参数是基本数据类型,则形参的改变不影响实际参数 如果方法的参数是引用数据类型,形式参数的改变会影响实参...
形参 与运算 引用数据类型 基本数据类型