L = []
i=1
while True:
L.append(i*i)
i+=1
if i>100:
break
print sum(L)
i=1
while True:
L.append(i*i)
i+=1
if i>100:
break
print sum(L)
2015-08-28
t = math.sqrt(b * b - 4 * a * c)
return (-b + t) / (2 * a),( -b - t )/ (2 * a)
return (-b + t) / (2 * a),( -b - t )/ (2 * a)
2015-08-28
def square_of_sum(L):#定义一个函数名称
sum=0 #定义一个变量
for x in L: #遍历所有值
sum+=x*x #累计每一个取值
return sum #返回最终的结果
sum=0 #定义一个变量
for x in L: #遍历所有值
sum+=x*x #累计每一个取值
return sum #返回最终的结果
2015-08-28
for x in [10,20,30,40,50,60,70,80,90 ]:
for y in [0,1,2,3,4,5,6,7,8,9]:
if x/10<y:
print x+y
for y in [0,1,2,3,4,5,6,7,8,9]:
if x/10<y:
print x+y
2015-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 x < y:
print x+y
for y in ['1','2','3','4','5','6','7','8','9']:
if x < y:
print x+y
2015-08-27
x=1
sum=0
while 2*x-1<=100:
sum=2*x-1+sum
x=x+1
print sum
答案2500 下面一堆错的
sum=0
while 2*x-1<=100:
sum=2*x-1+sum
x=x+1
print sum
答案2500 下面一堆错的
2015-08-27
def firstCharUpper(s):
return s.upper()[:1] + s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s.upper()[:1] + s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2015-08-27
return ('<tr><td>%s</td><td>%s</td></tr>' if score > 60 else '<tr><td>%s</td><td style="color:red">%s</td></tr>') % (name, score)
2015-08-27
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score) if score > 60 else '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
2015-08-27