Python 2.5.2
Version of implementation CPython of programming language PythonBugfix release: over 100 bugs and patches have been addressed since Python 2.5.1, many of them improving the stability of the interpreter, and improving its portability.
Examples:
Hello, World! - Python (52):
print "Hello, World!"
Factorial - Python (53):
This example uses recursive factorial definition.
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
for n in range(16 + 1):
print "%d! = %d" % (n, factorial(n))
Fibonacci numbers - Python (61):
This example uses recursive definition of Fibonacci numbers.
#! /usr/bin/env python
def fibonacci(n):
if n < 3:
return 1
else:
return fibonacci(n - 1) + fibonacci(n - 2)
for n in range(1, 16 + 1):
print "%i," % fibonacci(n) ,
print "..."
Factorial - Python (377):
This example uses iterative method of calculating factorials.
def factorial(n):
if n == 0:
return 1
f = 1
for i in range(1, n + 1):
f *= i
return f
for n in range(16 + 1):
print "%d! = %d" % (n, factorial(n))
Comments
]]>blog comments powered by Disqus
]]>