print('hello world')
def test1():
print(123455)
test1()
c=test1
c()
print(id(c))
print(id(test1))
a=8
def test2():
b=3
print(b*2)
global a
a=50
test2()
print(a)
import time
import math
def test1():
start=time.time()
for i in range(100000):
math.sqrt(36)
end=time.time()
print('耗时{0}'.format((end-start)))
def test2():
a=math.sqrt
start = time.time()
for i in range(100000):
a(36)
end = time.time()
print('耗时{0}'.format((end - start)))
test1()
test2()
a=[1,2]
print(id(a))
print(a)
def test1(m):
print(id(m))
m.append(3)
print(id(m))
test1(a)
print(a)
import copy
def testcopy():
a=[1,2,[1,2]]
b=copy.copy(a)
print('a:',a)
print('b:',b)
print('浅拷贝')
b.append(3)
b[2].append(3)
print('a:',a)
print('b:',b)
testcopy()
print('********************')
def testdeepcopy():
a=[1,2,[1,2]]
b=copy.deepcopy(a)
print('a:',a)
print('b:',b)
print('深拷贝')
b.append(3)
b[2].append(3)
print('a:',a)
print('b:',b)
testdeepcopy()
def test1(a,b,c,d):
print(a,b,c,d)
test1(1,2,3,4)
test1(d=4,b=2,a=1,c=3)
def test2(a,b,c,d=4):
print(a,b,c,d)
test2(1,2,3)
def t1(a,b,*c):
print(a,b,c)
t1(1,2,3,4,5,6)
def t2(a,b,*c,**d):
print(a,b,c,d)
t2(1,2,3,4,5,age=19)
def t3(*a,b,c):
print(a,b,c)
t3(1,2,3,4,b=5,c=6)
'''一个星号代表元组,两个星号代表字典。星号在前后面的参数必须强制命名'''
f= lambda a,b,c,d:a*b*c*d
print(f(1,2,3,4))
g=lambda a:a*4,lambda b:b*4
print(g[0](5))
e="print('abcd')"
eval(e)
a=1
b=2
print(eval('a+b'))
dict1=dict(a=100,b=20)
print(eval('a+b',dict1))
def test1(n):
print('test1:',n)
if n==0:
print('over')
else:
test1(n-1)
print('test1:**',n)
test1(5)
def f(n):
if n==1:
return 1
else:
return n*f(n-1)
print(f(6))