def fact(n): if not n: return 0 if n == 1: return 1 return fact(n - 1) * n print fact(7) print fact(3) class Person(): def __init__(self, name = None, address = None): self.name = name self.address = address def __str__(self): result = '' if self.name: result += self.name if self.address: result += ', %s' % (self.address, ) return result alexey = Person(name = 'Alexey Pogodin') john = Person(name = 'John Smith', address = '100 Main Street') print alexey print john
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question