Upgrade to Pro — share decks privately, control downloads, hide ads and more …

弄蛇人的程式語言入門

 弄蛇人的程式語言入門

2014/07/15 Workshop @ SITCON Summer Camp 2014, National Chengchi University, Taipei, Taiwan

Poren Chiang

July 15, 2014
Tweet

More Decks by Poren Chiang

Other Decks in Technology

Transcript

  1. ශ⣹̍ḑ⁰෇⯅⭚ӧ㉊
    RSChiang @ SITCON Summer Camp 2014
    H O W T O T R A I N Y O U R P Y T H O N

    View full-size slide

  2. ߐ㡦࿝ዅ RSChiang
    • 112 ᝖୪㋁
    • SITCON / COSCUP ⵈⶦ೸
    • Python ჿࢼ␹
    • You can reach me at http://poren.tw

    View full-size slide

  3. ⁰෇ḑ༦⏯

    View full-size slide

  4. 民法 158 條
    要約定有承諾期限者,⾮非於其期限
    內為承諾,失其拘束⼒力。︒。
    ⬉≜.send()
    try:
    ါⰊ = ⬉≜.wait()
    except TimeoutException:
    ⬉≜ = null
    ቒ୕ ⁰෇

    View full-size slide

  5. Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.
    Flat is better than nested.
    Sparse is better than dense.
    Readability counts.

    View full-size slide

  6. #include
    using namespace std;
    !
    int main(int argc, char* argv)
    {
    cout << “Hi SITCON!”;
    return 0;
    }
    print(“Hi SITCON!”)
    C++ Python

    View full-size slide

  7. string a = “ݙ”;

    string b = “”;
    for (int i = 1; i <= 5; i++)
    {
    b += a;
    }
    cout << b;
    print(“ݙ” * 5)
    C++ Python

    View full-size slide

  8. for (int i = 1; i <= 5; i++)
    {
    cout << “#” << i << “\n”;
    }
    for i in range(5):
    print(“#” + str(i))
    C++ Python

    View full-size slide

  9. captains = [‘Takeshi’, ‘ୖ⭘’, ‘EAT’, ‘┧㕕’]
    for captain in captains:
    print(‘Captain ’ + captain)
    print(len(captains))

    View full-size slide

  10. speakers = [‘Allen’, ‘Bob’, ‘RS’, ‘⒀㐷’]
    for i, speaker in enumerate(speakers):
    print(‘#{0} - {1}’.format(i, speaker))
    print(len(captains))

    View full-size slide

  11. Live Examples

    View full-size slide

  12. reduce(
    lambda a, b: a or b,
    [
    x % i == 0
    for i in range(
    2,
    int(x ** 0.5 + 1)
    )
    ]
    )

    View full-size slide