L = []
a=1
while "TRUE":
L.append(a*a)
a+=1
if a>100:
break
print sum(L)
a=1
while "TRUE":
L.append(a*a)
a+=1
if a>100:
break
print sum(L)
2019-01-30
用2个for就可以了,因为是三位数对称,首尾和末尾都一样
print [i*100+j*10+i] for i in range(1,10) for j in range(10)]
print [i*100+j*10+i] for i in range(1,10) for j in range(10)]
2019-01-30
import math
def quadratic_equation(a, b, c):
if a == 0:
return -1(c/b)
else:
if b*b >= 4*a*c:
return (-b - math.sqrt(b*b - 4*a*c))/(2*a), (-b + math.sqrt(b*b - 4*a*c))/(2*a)
else:
return
这样写才是正确的
def quadratic_equation(a, b, c):
if a == 0:
return -1(c/b)
else:
if b*b >= 4*a*c:
return (-b - math.sqrt(b*b - 4*a*c))/(2*a), (-b + math.sqrt(b*b - 4*a*c))/(2*a)
else:
return
这样写才是正确的
2019-01-30
L = ['Adam', 'Lisa', 'Bart']
L.insert(-1,'Paul')
print L
看来不严谨啊,逆序查找就出错。哈哈
L.insert(-1,'Paul')
print L
看来不严谨啊,逆序查找就出错。哈哈
2019-01-30