• Python functions can contain two types of arguments: positional arguments and keyword arguments.

    • Positional arguments must be included in the correct order. (順序一定要正確)
    • Keyword arguments are included with a keyword and equal sign.(順序不一定要依序)
      • (positional argument_位置對應)
      • (keyword argument parameter 等號定義)
    
    # Postional Argument
    
    def exponent(a, b):  # 定義的exponent 會print a,b 參數,給入2的3次方 argument 定值計算 print 出來
        print(a ** b)
    
    exponent(2, 3)
    
    def exponent(a, b):  # 定義的function 會 return a,b 參數進行a 的b 次方運算
        return a ** b
    
    exponent(2, 3) # 為什麼執行function 時不會直接跑return value  要用print function 再包 exponent
    print(exponent(2, 3))
    
    print(exponent(3, 2)) # print (2,3) 和print(3,2) 會不同 postional arugment 是抓相對位置 (order)
    
    -----------------------------------------------------------------------------
    8
    8 -->exponent (2,3)
    9 ---> exponent(3,2)
    
    # keyword argument
    
    def exponent(a, b):
        return a ** b
    
    print(exponent(a=2, b=3))
    print(exponent(b=3, a=2)) #有keyword 定義時 就不會因為對應位置改變而有影響
    
    ------------------------
    8
    8 
    
    
    # test 
    mylist = [ 4, 6, 3, 2, 1]
    
    print(sorted(mylist, reverse=False))
    # mylist is positional argument 
    # reverse = False is keyword argument