Python 练习实例47
题目:两个变量值互换。
程序分析:无
程序源代码:
实例
#!/usr/bin/python
# -*- coding: UTF-8 -*-
def exchange(a,b):
a,b = b,a
return (a,b)
if __name__ == '__main__':
x = 10
y = 20
print ('x = %d,y = %d' % (x,y))
x,y = exchange(x,y)
print ('x = %d,y = %d' % (x,y))
# -*- coding: UTF-8 -*-
def exchange(a,b):
a,b = b,a
return (a,b)
if __name__ == '__main__':
x = 10
y = 20
print ('x = %d,y = %d' % (x,y))
x,y = exchange(x,y)
print ('x = %d,y = %d' % (x,y))
以上实例输出结果为:
x = 10,y = 20 x = 20,y = 10
等一个人
252***465@qq.com
参考方法:
等一个人
252***465@qq.com
不知道叫啥
114***5830@qq.com
参考方法:
不知道叫啥
114***5830@qq.com
朦胧
253***5732@qq.com
Python3 测试:
朦胧
253***5732@qq.com
Webben
wei***_li@126.com
异或运算:
Webben
wei***_li@126.com
chengxuyuan
hdw***taoyuan@foxmail.com
参考:
chengxuyuan
hdw***taoyuan@foxmail.com
段祺晟
475***057@qq.com
python3:
段祺晟
475***057@qq.com