print [x*100+y*10+z for x in range(1,10)
for y in range(0,10) for z in range(1,10) if x==z
]
for y in range(0,10) for z in range(1,10) if x==z
]
2015-08-19
输出正确。
sum = 0
x = 1
while 2x+1<100:
sum = x + sum
x=x+1
print sum
sum = 0
x = 1
while 2x+1<100:
sum = x + sum
x=x+1
print sum
2015-08-18
def firstCharUpper(s):
return s[0].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[0].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2015-08-18
L=[]
i=1
while i<=100:
L.append(i*i)
i+=1
print sum(L)
L=[]
for i in range(1,101):
L.append(i*i)
print sum(L)
i=1
while i<=100:
L.append(i*i)
i+=1
print sum(L)
L=[]
for i in range(1,101):
L.append(i*i)
print sum(L)
2015-08-18
def square_of_sum(L):
sum=0
for x in L:
sum+=x*x
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
sum=0
for x in L:
sum+=x*x
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2015-08-18
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
2015-08-18
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for hh in d:
print hh,':',d.get(hh)
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for hh in d:
print hh,':',d.get(hh)
2015-08-18