Skip to content

Instantly share code, notes, and snippets.

@dketov
Created December 13, 2011 14:06
Show Gist options
  • Save dketov/1472235 to your computer and use it in GitHub Desktop.
Save dketov/1472235 to your computer and use it in GitHub Desktop.
Определение функции
# -*- encoding: utf-8 -*-
"""
Определение функции
"""
def square(x):
'Calculates the square of the number x.'
return x*x
print square(100)
def factorial(n):
result = n
for i in range(1,n):
result *= i
return result
print factorial(10)
def fib(n): # write Fibonacci series up to n
"""Print a Fibonacci series up to n."""
a, b = 0, 1
while b < n:
print b,
a, b = b, a+b
# Now call the function we just defined:
fib(2000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment