第 19讲: 我的地盘听我的

0. 函数和过程:

>>> def test():
print("hello")


>>> print(test())
hello
None

1.返回值: 

>>> def test():
  return[1,3,"小甲鱼"]

>>> test()
[1, 3, '小甲鱼']
>>>

>>> def test():
  return(1,3,"小甲鱼")

>>> test()
(1, 3, '小甲鱼')
>>>
>>>

2. 函数变量的作用域:

def discounts(price, rate):
final_price = price * rate
return final_price

old_price = float(input("请输入原件:"))
rate = float(input('请输入折扣率:'))
new_price = discount(old_price, rate)
print('打折后价格是:', new_price)

原文地址:https://www.cnblogs.com/jiangkeji/p/9086949.html