sum = 0
x = 1
while x%2==1 and x<=100:
sum=sum+x
x=x+1
print sum
x = 1
while x%2==1 and x<=100:
sum=sum+x
x=x+1
print sum
2018-05-22
sum = 0
x = 1
n = 1
while True:
sum=sum+x
x=x*2
n=n+1
if n >20:
break
print sum
x = 1
n = 1
while True:
sum=sum+x
x=x*2
n=n+1
if n >20:
break
print sum
2018-05-22
x1 = 1
d = 3
n = 100
x100 = x1+3*99
s = (x1+x100)*50
print s
d = 3
n = 100
x100 = x1+3*99
s = (x1+x100)*50
print s
2018-05-22
def toUppers(L):
return [x.upper() for x in L if isinstance(x,str)]
print toUppers(['Hello', 'world', 101])
return [x.upper() for x in L if isinstance(x,str)]
print toUppers(['Hello', 'world', 101])
第二种解法:s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x not in s:
s.add(x)
else:
L.remove(x)
print (s)
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x not in s:
s.add(x)
else:
L.remove(x)
print (s)
2018-05-22
这题绕的有点晕s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
L.remove(x)
else:
s.add(x)
print(s)
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
L.remove(x)
else:
s.add(x)
print(s)
2018-05-22
我的环境变量这样显示、一直都没有办法配置成功,哪位大神帮忙看一下啊,%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static:C:\Python27
2018-05-21
d={'Adam':95,'Lisa':85,'Bart':59,'Paul':74}
a=d.values()
print sum(a)/len(d)
a=d.values()
print sum(a)/len(d)
2018-05-21