Python學習記錄-2016-01-21

來源:互聯網
上載者:User

標籤:return   絕對值   school   記錄   

今日學習記錄:

函數部分:

局部變數和全域變數之間的關係,已經範圍:

school = "Oldboy"def test1()    school = "Jack"    return 0#預設先使用局部變數,如果局部變數和全域變數衝突,局部變數只在這個函數起作用;school = "Oldboy"def test1()    global school    school = "Jack"    return 0

#如此可以修改全域變數,但,不推薦使用。

遞迴:

def test1(n)    if n/2 > 0        return test1(n/2)

遞迴的特點:

1、必須有明確的允出準則

2、範圍必須逐漸減少

3、效率低,採用類似於C協議棧的方式,目前是999次。

Function Compute:

真正的函數,類似於y=2x這種,一個輸入有一個肯定的輸出,一般應用是hashshell等

高階函數,在變數中採用函數:

def test1(x,y,f)    sub = f(x) +f(y)    print(sub)f = abs#abs作用,abs(-3)=3,abs是絕對值的作用。








Python學習記錄-2016-01-21

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.