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-08-28
sum = 0
x = 1
n = 1
while True:
sum=sum+x
x=pow(2,n)
n=n+1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum=sum+x
x=pow(2,n)
n=n+1
if n>20:
break
print sum
2018-08-28
首先第一个,a因为不为空,所以或返回a 的值;
第二个是b为空值,Python定义空值为 0或者False,所以或返回是字符串world
第二个是b为空值,Python定义空值为 0或者False,所以或返回是字符串world
2018-08-28
交作业
#input code
print 'hello,python.'
print 'hello,','python.'
#input code
print 'hello,python.'
print 'hello,','python.'
2018-08-28
sum = 0
x = 1
while x<100:
if x%2!=0:
sum=sum+x
x=x+1
print sum
x = 1
while x<100:
if x%2!=0:
sum=sum+x
x=x+1
print sum
2018-08-27
for x in ['1','2','3','4','5','6','7','8','9']:
for y in ['1','2','3','4','5','6','7','8','9']:
if int(x)<int(y):
print x+y
哈哈哈笨死了
for y in ['1','2','3','4','5','6','7','8','9']:
if int(x)<int(y):
print x+y
哈哈哈笨死了
2018-08-27
sum = 0
x = 1
while x <= 100:
sum += x%2 == 0 ? 0 : x
print sum
x = 1
while x <= 100:
sum += x%2 == 0 ? 0 : x
print sum
2018-08-26