s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for l in L:
if l in s:
s.remove(l)
else:
s.add(l)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for l in L:
if l in s:
s.remove(l)
else:
s.add(l)
print s
2018-05-12
s = set(['Adam','Lisa','Bart','Paul'])
print 'Adam' in s
print 'Bart' in s
# 有的同学可能是题目理解错了
print 'Adam' in s
print 'Bart' in s
# 有的同学可能是题目理解错了
2018-05-12
要的不是这个效果吗?
for x in [0,1,2,3,4,5,6,7,8,9]:
for y in [0,1,2,3,4,5,6,7,8,9]:
#print x,y
if x < y:
print x,y,'(',x,'<',y,')'
for x in [0,1,2,3,4,5,6,7,8,9]:
for y in [0,1,2,3,4,5,6,7,8,9]:
#print x,y
if x < y:
print x,y,'(',x,'<',y,')'
2018-05-12
sum = 0
x = 1
while True:
if x%2 ==1:
sum = sum + x
x = x + 1
if x > 100:
break
print sum
# what so easy?
x = 1
while True:
if x%2 ==1:
sum = sum + x
x = x + 1
if x > 100:
break
print sum
# what so easy?
2018-05-12
sum = 0
x = 1
n = 1
while True:
sum = sum + x
x = 2 * x;
n = n + 1
print x
if n > 20:
break
print sum
# 这难道就是传说中的等比数列
x = 1
n = 1
while True:
sum = sum + x
x = 2 * x;
n = n + 1
print x
if n > 20:
break
print sum
# 这难道就是传说中的等比数列
2018-05-12
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
sum = sum + x;
x = x + 1;
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
sum = sum + x;
x = x + 1;
print sum
2018-05-12
sum = 0
x = 1
n = 1
while True:
x= 2*x
sum+=x
n=n+1
if n>19:
sum+=1
break
print sum
x = 1
n = 1
while True:
x= 2*x
sum+=x
n=n+1
if n>19:
sum+=1
break
print sum
2018-05-12