for x in range(1,10):#0~9
for y in range(1,10):#0~9
if x < y:
print x * 10 + y
for y in range(1,10):#0~9
if x < y:
print x * 10 + y
2015-03-29
for x in [ 1,2,3,4,5,6,7,8,9 ]:
for y in [ 1,2,3,4,5,6,7,8,9 ]:
if x<y:
print x*10+y
因为事先明显知道整十的数不满足要求,可以不用考虑,忽略y中的0,速度更快
for y in [ 1,2,3,4,5,6,7,8,9 ]:
if x<y:
print x*10+y
因为事先明显知道整十的数不满足要求,可以不用考虑,忽略y中的0,速度更快
2015-03-29
sum = 0
x = 99
while x>=1:
sum+=x
x = x - 2
print sum
这种方式虽然不是标准答案,但是貌似更简单
x = 99
while x>=1:
sum+=x
x = x - 2
print sum
这种方式虽然不是标准答案,但是貌似更简单
2015-03-29
sum = 0
x = 1
n = 1
while n<=20:
sum+=x
x*=2
n+=1
print sum
x = 1
n = 1
while n<=20:
sum+=x
x*=2
n+=1
print sum
2015-03-29
最新回答 / martingeng
s = set(['Adam', 'Lisa', 'Paul'])L = ['Adam', 'Lisa', 'Bart', 'Paul']for name in L: if name in s: s.remove(name) else: s.add(name)print s<...code...>
2015-03-28
已采纳回答 / Captain_Lin
cd是打开目录,如果你的HELLO.PY不在C盘的话,比如在D盘,直接输入【D:】,会自动跳到PY所在的文件夹,然后直接在后面输入【python hello.py】就好了
2015-03-28
字符串是双引号包括的
t = ('a', 'b', str("A,B"))
l=t[2]
print l #A,B
print l[0],l[1],l[2]#A , B
t = ('a', 'b', str("A,B"))
l=t[2]
print l #A,B
print l[0],l[1],l[2]#A , B
2015-03-28
L = ['Adam', 'Lisa', 'Bart']
L[-1]=L[-3]
L[-3]='Bart'
print L
L[-1]=L[-3]
L[-3]='Bart'
print L
2015-03-28