i=0
x1=1
x2=1
for i in range(99):
x1+=3
x2+=x1
i+=1
print x2
x1=1
x2=1
for i in range(99):
x1+=3
x2+=x1
i+=1
print x2
2018-06-10
教程用的编辑器是2.7版本的吧。2.5+10/4这个式子,在3.6.5的编辑器里,得到的就是5.0的结果。在教程编辑器中需写成:2.5+10.0/4
2018-06-08
sum = 0
x = 1
n = 1
while True:
sum = sum+x
x = 2*x
n += 1
if n > 20:
break
print (sum)
x = 1
n = 1
while True:
sum = sum+x
x = 2*x
n += 1
if n > 20:
break
print (sum)
2018-06-06
个人觉得这样写比较好,+表示拼接,用两个加号表达的很清楚,我是不太理解print里面逗号的使用
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key +':'+ str(d[key])
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key +':'+ str(d[key])
2018-06-06