位置參數

位置參數函數

  定義位置參數函數spa

    def power(x, n): #函數有兩個參數:x和n,這兩個參數都是位置參數,調用函數時,傳入的兩個值按照位置順序依次賦給參數x和n
      s = 1
      while n > 0:
        n = n - 1
        s = s * x
      return s

 

 

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------code

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------blog

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------class

相關文章
相關標籤/搜索