整合重點

Python 函式入門

Hugo Bowne-Anderson

Instructor

你已學到:

  • 如何撰寫函式

    • 接受多個參數

    • 回傳多個值

  • 接下來:用於分析 Twitter 資料的函式

Python 函式入門

函式的基本組成

  • 函式標頭
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 函式入門

一起來練習吧!

Python 函式入門

Preparing Video For Download...