Python 函式入門
Hugo Bowne-Anderson
Instructor
如何撰寫函式
接受多個參數
回傳多個值
接下來:用於分析 Twitter 資料的函式
def raise_both(value1, value2):
"""Raise value1 to the power of value2
and vice versa."""
new_value1 = value1 ** value2
new_value2 = value2 ** value1
new_tuple = (new_value1, new_value2)
return new_tuple
Python 函式入門