第一段“在Python中,如果给定一个list或tuple,我们可以通过for循环来遍历这个list或tuple,这种遍历我们成为迭代(Iteration)。”“成为”应该是“称为”
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
d['Paul']=75
print d
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
d['Paul']=75
print d
2018-11-16
sum = 0
x = 2
n = 0
while True:
x=x^n
n+=1
sum+=x
if n>=20:
break
print sum
x = 2
n = 0
while True:
x=x^n
n+=1
sum+=x
if n>=20:
break
print sum
2018-11-16
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
elif x%2<>0:
continue
sum=sum+x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
elif x%2<>0:
continue
sum=sum+x
print sum
2018-11-15
x1 = 1
d = 3
n = 100
x100 = x1 + n*(n-1)*d
s = n*x1 + n*(n-1)/2*d
print s
d = 3
n = 100
x100 = x1 + n*(n-1)*d
s = n*x1 + n*(n-1)/2*d
print s
2018-11-15
L = []
x=0
while x<100:
x=x+1
L.append(x*x)
print sum(L)简单明了就好
x=0
while x<100:
x=x+1
L.append(x*x)
print sum(L)简单明了就好
2018-11-15
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for name in s:
L=list(name)
print L[0]+":",L[1]
for name in s:
L=list(name)
print L[0]+":",L[1]
2018-11-14
sum = 0
x = 1
while x<100:
x=x+1
if x%2!=0:
sum+=x
print sum+1
x = 1
while x<100:
x=x+1
if x%2!=0:
sum+=x
print sum+1
2018-11-13
print [m*100+n*10+l for m in range(1,10) for n in range(1,10) for l in range(1,10) if m==l if n==m+1]
真的是函数学的最差,这是我的命门,别的都好很多。
真的是函数学的最差,这是我的命门,别的都好很多。
2018-11-13
for x in range(100):
a=x//10
b=x%10
if a!=0:
if a<b:
print x
a=x//10
b=x%10
if a!=0:
if a<b:
print x
2018-11-13