-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop.py
executable file
·59 lines (44 loc) · 903 Bytes
/
loop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# circlr.py
def addSum(x,y):
return x+y
def showMeg(name , gender , age = 8):
print name , gender , age
def add_end(l = None):
if l is None:
l = []
l.append('end')
return l
def calc(*nums):
sum = 0
for x in nums:
sum = sum + x
return sum
def person(name , age , **kw):
print name, age, kw
@tail_call_optimized
def fact(n):
return fact_tail(1,1,n)
def fact_tail(product , index , n):
if index > n:
return product
return fact_tail(product * index , index + 1 , n)
print(fact(10))
person('das',12)
person('sitong', 56 , **{'s':12 , 'asd':43})
print calc(1,2,3)
print calc(*[1,2,5])
print(add_end())
print(add_end())
print(add_end())
print(add_end([1,2,3]))
list = (1,2,3,'sitong')
for name in list:
print name
n = 0
for x in xrange(1,10):
n = addSum(x,n)
print n
showMeg( 'sitong' , '男')
showMeg( 'houqi' , '男', 78)