L = []
for x in range(1,10):
for y in range(0,10):
for z in range(0,10):
if x==z:
L.append(x*100+y*10+z)
print L
for x in range(1,10):
for y in range(0,10):
for z in range(0,10):
if x==z:
L.append(x*100+y*10+z)
print L
2020-04-19
python 3.7 中 set 格式是:
s = {'A', 'B', 'C'}
print(s)
s = {'A', 'B', 'C'}
print(s)
2020-04-16
def sum(n):
sum = 0
for i in range(1,n+1):
i = i * i
sum = sum + i
return sum
print sum(100)
sum = 0
for i in range(1,n+1):
i = i * i
sum = sum + i
return sum
print sum(100)
2020-04-15
l=[]
for m in range(1,10):
for n in range(0,10):
for j in range(1,10):
if m==j:
l.append(m*100+n*10+j)
print l
for m in range(1,10):
for n in range(0,10):
for j in range(1,10):
if m==j:
l.append(m*100+n*10+j)
print l
2020-04-15
print [m*100+n*10+j for m in range(1,10) for n in range(0,10) for j in range(1,10) if m==j]
2020-04-15
>>> classMate = set(['Adam','Lisa','Paul'])
>>> print(classMate)
{'Adam', 'Lisa', 'Paul'}
>>> print(classMate)
{'Adam', 'Lisa', 'Paul'}
2020-04-15
优先执行age>=6了,要在设置一个上线
if 18 > age >= 6:
print ('teenager')
elif age >= 18:
print ('adult')
就输出了adult
if 18 > age >= 6:
print ('teenager')
elif age >= 18:
print ('adult')
就输出了adult
2020-04-14
>>> L[-1:-11]
range(100, 90)
>>> L[-1:-49:5]
range(100, 52, 5)
其实仔细想一下,我得这种做法也是对的,只不过这样看起来不好看,range(100,90)起始100包含,最后90不包含,中间10个数字不是一样的嘛,只是没有正序好看而已
range(100, 90)
>>> L[-1:-49:5]
range(100, 52, 5)
其实仔细想一下,我得这种做法也是对的,只不过这样看起来不好看,range(100,90)起始100包含,最后90不包含,中间10个数字不是一样的嘛,只是没有正序好看而已
if args==():
return 0.0
else:
sum=0
for s in args:
sum=sum+s
return sum/(float)(len(args))
这种写法更容易看懂,大致想法是一样的
return 0.0
else:
sum=0
for s in args:
sum=sum+s
return sum/(float)(len(args))
这种写法更容易看懂,大致想法是一样的
2020-04-13