sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
elif x%2==1:
sum=sum+x
continue
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
elif x%2==1:
sum=sum+x
continue
print sum
2018-06-25
for x in range(1,10):
for y in range(10):
if x<y:
print x*10+y
for y in range(10):
if x<y:
print x*10+y
2018-06-25
sum = 0
x = 1
n = 1
while True:
sum+=x
if n>=20:
break
x*=2
n+=1
print sum
x = 1
n = 1
while True:
sum+=x
if n>=20:
break
x*=2
n+=1
print sum
2018-06-25
for x in [ 1,2,3,4,5,6,7,8,9 ]:
for y in [ 0,1,2,3,4,5,6,7,8,9 ]:
if x < y:
print x*10+y
#print x*10+y,'(',x,'<',y,')'
for y in [ 0,1,2,3,4,5,6,7,8,9 ]:
if x < y:
print x*10+y
#print x*10+y,'(',x,'<',y,')'
2018-06-25
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop(2)
print L
或者
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop()
L.pop()
print L
L.pop(2)
L.pop(2)
print L
或者
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop()
L.pop()
print L
2018-06-24
L = [95.5,85,59]
print L[0]
print L[1]
print L[2]
#print L[3]
print L[0]
print L[1]
print L[2]
#print L[3]
2018-06-24
a=0
for i in range(101):
if i%3==1:
a+=i
print(a)
a=0
for i in range(301):
if i%3==1:
a+=i
print(a)
for i in range(101):
if i%3==1:
a+=i
print(a)
a=0
for i in range(301):
if i%3==1:
a+=i
print(a)
2018-06-24
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
m = set(L)
print s^m # 对称差集
L = ['Adam', 'Lisa', 'Bart', 'Paul']
m = set(L)
print s^m # 对称差集
2018-06-22
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print(s)
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print(s)
2018-06-22
s = set(['Adam', 'Lisa', 'Bart', 'Paul'])
print 'adam'.title() in s
print 'bart'.title() in s
print 'adam'.title() in s
print 'bart'.title() in s
2018-06-22