先删除第三个,在删除第二个,即调换两个输出语句的位置。;或者删除第二个,因为已经调整位置了,再删除一次第二个就可以了。即两次pop(2).
2015-09-25
在第一个print语句中,a = 'python',a为True,结果必为True,所以输出helo,python.
第二个print语句中,b = '',结果取决于后面的'world',所以输出hello,world
第二个print语句中,b = '',结果取决于后面的'world',所以输出hello,world
2015-09-25
t = ('a', 'b', ['A', 'B'])
t = list(t)
t[2] = ('a','b')
t = tuple(t)
print t
t = list(t)
t[2] = ('a','b')
t = tuple(t)
print t
2015-09-24
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
print L
L.pop(2)
print L
要分开因为第一删了之后,列表中的位置会发生改变
L.pop(2)
print L
L.pop(2)
print L
要分开因为第一删了之后,列表中的位置会发生改变
2015-09-24
print r'''"to be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''
Whether it's nobler in the mind to suffer.'''
2015-09-24
for x in range(1,10):
for y in range(0,10):
if x<y:
print x*10 +y
for y in range(0,10):
if x<y:
print x*10 +y
2015-09-23
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2==0:
continue
else:
sum += x
print sum
#或者不使用continue
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2:
sum += x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2==0:
continue
else:
sum += x
print sum
#或者不使用continue
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2:
sum += x
print sum
2015-09-23
sum = 0
x = 1
while x<100:
if x%2==0:
continue
sum = sum + x
x = x + 1
print sum
这么写有什么错吗?怎么老是报错
x = 1
while x<100:
if x%2==0:
continue
sum = sum + x
x = x + 1
print sum
这么写有什么错吗?怎么老是报错
2015-09-23
print [100*a+10*b+c for a in range(1,10) for b in range(0,10) for c in range(0,10) if a==c]
2015-09-22
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print x[0],':',x[1]
for x in s:
print x[0],':',x[1]
2015-09-22
sum = 0
x = 1
while True:
if x % 2:
sum = sum + x
x = x + 1
if x > 100:
break
print sum
x = 1
while True:
if x % 2:
sum = sum + x
x = x + 1
if x > 100:
break
print sum
2015-09-21