s=[]
for m in range(1,10):
for n in range(0,10):
for z in range(1,10):
if m==z:
s.append(m*100+n*10+z)
print s
for m in range(1,10):
for n in range(0,10):
for z in range(1,10):
if m==z:
s.append(m*100+n*10+z)
print s
2015-09-05
for m in range(0,10):
for n in range(0,10):
for z in range(0,10):
if m or z>0:
if m==z:
print m*100+n*10+z
for n in range(0,10):
for z in range(0,10):
if m or z>0:
if m==z:
print m*100+n*10+z
2015-09-05
for m in range(1,10):
for n in range(1,10):
for z in range(1,10):
if m==z:
print m*100+n*10+z
for n in range(1,10):
for z in range(1,10):
if m==z:
print m*100+n*10+z
2015-09-05
a=[]
b=[]
c=[]
for i in range(1,101,2):
a.append(i)
for x in range(2,101,2):
b.append(x)
for x,y in zip(a,b):
c.append(x*y)
print c
b=[]
c=[]
for i in range(1,101,2):
a.append(i)
for x in range(2,101,2):
b.append(x)
for x,y in zip(a,b):
c.append(x*y)
print c
a=[]
b=[]
c=[]
for i in range(1,101,2):
a.append(i)
for x in range(2,101,2):
b.append(x)
for x,y in zip(a,b):
print x,'x',y
是生成列表还是计算结果生成列表= =
b=[]
c=[]
for i in range(1,101,2):
a.append(i)
for x in range(2,101,2):
b.append(x)
for x,y in zip(a,b):
print x,'x',y
是生成列表还是计算结果生成列表= =
def move(n, a, b, c):
if n == 1:
print a,'-->',c
else:
move((n-1),a,c,b)
move(1,a,b,c)
move((n-1),b,a,c)
move(4, 'A', 'B', 'C')
if n == 1:
print a,'-->',c
else:
move((n-1),a,c,b)
move(1,a,b,c)
move((n-1),b,a,c)
move(4, 'A', 'B', 'C')
2015-09-04
x1 = 1
d = 3
n = 100
x100 = x1 + (n-1)*d
s = (x1+x100)*n/2
print s
d = 3
n = 100
x100 = x1 + (n-1)*d
s = (x1+x100)*n/2
print s
2015-09-04
此处计算的是 a or b
只要先出现的是ture,则只计算到ture (第一步中的a为ture,则显示a)
如果先出现的是false,则取决于下一个数(第二布中的b为空值,显示为flase,取决于后面的数值是flase还是ture来进行判断,所以显示的是后面的字符)
只要先出现的是ture,则只计算到ture (第一步中的a为ture,则显示a)
如果先出现的是false,则取决于下一个数(第二布中的b为空值,显示为flase,取决于后面的数值是flase还是ture来进行判断,所以显示的是后面的字符)
2015-09-04
>>> d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
>>> for a , b in d.items ():
print a ,":" ,b
Lisa : 85
Adam : 95
Bart : 59
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
>>> for a , b in d.items ():
print a ,":" ,b
Lisa : 85
Adam : 95
Bart : 59
2015-09-04
>>> d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
>>> for i in d :
print i , ":" ,d[i]
Lisa : 85
Adam : 95
Bart : 59
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
>>> for i in d :
print i , ":" ,d[i]
Lisa : 85
Adam : 95
Bart : 59
2015-09-04
>>> x = 1
>>> while x <=0:
sum = x
x = x+2
sum +=x
print sum
>>>
>>> sum
2500
>>> while x <=0:
sum = x
x = x+2
sum +=x
print sum
>>>
>>> sum
2500
2015-09-04
>>> x = 1
>>> for t in range (2,101):
if t%2 <>0:
x = x+t
print x
>>> for t in range (2,101):
if t%2 <>0:
x = x+t
print x
2015-09-04