Created
October 5, 2012 01:35
-
-
Save masayang/3837559 to your computer and use it in GitHub Desktop.
関数とクラス
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
class Stuffy(object): | |
def __init__(self, s = None): | |
self.buffer = s | |
def eek(self): | |
return self.buffer | |
if __name__ == '__main__': | |
s1 = Stuffy(10) | |
s2 = Stuffy(20) | |
print s1.eek() | |
print s2.eek() |
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
def factorial(n): | |
if n == 0: | |
return 1 | |
else: | |
return n * factorial(n - 1) | |
if __name__ == '__main__': | |
print factorial(10) | |
print factorial(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment