第 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)

posted @ 2018-05-25 10:04  Jenny测试开发  阅读(153)  评论(0编辑  收藏  举报