Created
May 24, 2014 04:58
-
-
Save masazdream/8f65c75ecae7950b164d to your computer and use it in GitHub Desktop.
初めてのPython 書式2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: UTF-8 | |
| # 関数 | |
| def hello(name, num=5): | |
| print "hello %s! " % name * num | |
| def hello2(name, num=4): | |
| return "hello %s!" % name * num | |
| #pass | |
| def hello3(): | |
| pass | |
| hello("brain", 2) | |
| hello("cluad", 4) | |
| hello("david") | |
| print hello2("mark") | |
| # 変数スコープ | |
| name = "imai" | |
| def hello(): | |
| name = "mark" | |
| print name | |
| def double(x): | |
| return x ** 2 | |
| print map(double, [2, 5, 8]) | |
| print map(lambda x:x * x, [2, 5, 8]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment