输出正确。
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
最新回答 / 邢方阁
dict内部存放的顺序和key放入的顺序是没有关系的。见 http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/00143167793538255adf33371774853a0ef943280573f4d000
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