我用Notepad++ v6.7.7编程,可被这个东东整死了。听前辈们说要用空格好。哪知道一直报错。全换成TAB键就能正常显示了。看来以后还是用TAB方便。
2015-05-09
print [m+n+m for m in '123456789' for n in '0123456789']
2015-05-09
x1 = 1
d = 3
n = 100
x100 = 100
s = 100*1+100*(100-1)/2*3
print s
d = 3
n = 100
x100 = 100
s = 100*1+100*(100-1)/2*3
print s
2015-05-08
t = ('a', 'b', ('A', 'B'))
print t
print t
2015-05-08
L = ['Adam', 'Lisa', 'Bart']
tem = L[0]
L[0] = L[2]
L[2] = tem
print L
替换即可?
tem = L[0]
L[0] = L[2]
L[2] = tem
print L
替换即可?
2015-05-08
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for k,v in d.iteritems():
print "%s:%s"%(k,v)
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for k,v in d.iteritems():
print "%s:%s"%(k,v)
2015-05-07
sum = 0
x = 1
n = 1
while True:
if n<21:
sum+=x
x=x*2
n+=1
else:
break
print sum
x = 1
n = 1
while True:
if n<21:
sum+=x
x=x*2
n+=1
else:
break
print sum
2015-05-07
不能,因为L.pop(2)执行后元素就剩下3个了,而此时Bart的索引就变成了2 所以该段程序不能正确的完成题目要求的任务
2015-05-07
sum = 0
x = 1
n = 1
while True:
sum += x * n
n *= 2
if n == 2 ** 20:
break
print sum
x = 1
n = 1
while True:
sum += x * n
n *= 2
if n == 2 ** 20:
break
print sum
2015-05-07
s = '''Python was started in 1989 by "Guido".\nPython is free and easy to learn.'''
print s
三个'''
print s
三个'''
2015-05-07
t = ('a','b','A','B'),这样改怎么不行啊
2015-05-06
d = {
'Adam':90,
'Lisa':85,
'Bart':90,
}
print len(d)
####显示结果为:3
'Adam':90,
'Lisa':85,
'Bart':90,
}
print len(d)
####显示结果为:3
2015-05-06