已采纳回答 / 算命0先生
dict的存储方式是通过hash_map存储结构,占内存大,存了value,key,next,但是查找速度快,时间复杂度为O(1)list查找时需要遍历整个元素,越靠后的元素查找越慢,但是占内存小
2016-09-22
最赞回答 / 岳阳白少
如果for循环中只写一个变量,那就是迭代dict中的key了,但是如果这样写变量,用逗号隔开,就可以找到key和value了d = {(2,3):95,'Lisa':85,'Bart':59,}for k,v in d.items(): print(k,':',v)
2016-09-22
L = ['Adam', 'Lisa', 'Bart']
L.insert(0,L.pop())
L.append(L.pop(1))
print L
L.insert(0,L.pop())
L.append(L.pop(1))
print L
2016-09-22
最新回答 / 慕粉4083696
我觉得学习还是要掌握“编程的思想”的,虽然我还是菜鸟级别。把题目用开闭区间表示: [90,+∞) : excellent, [80,90) : good, [60,80) : passed, (-∞ ,60):failed, 那么按顺序来呗:if score >= 90: print 'excellent'elif score >= 80: print 'good'elif score >= 60: print 'passed'else: print 'f...
2016-09-22
def quadratic_equation(a,b,c):
d = b*b -4*a*c
if d<0 :
return None
elif d == 0:
return -2*a/b
else :
return ((math.sqrt(b*b-4*a*c)+(-b))/2*a,(math.sqrt(b*b-4*a*c)+(-b))/2*a)
print(quadratic_equation(2,5,6))
d = b*b -4*a*c
if d<0 :
return None
elif d == 0:
return -2*a/b
else :
return ((math.sqrt(b*b-4*a*c)+(-b))/2*a,(math.sqrt(b*b-4*a*c)+(-b))/2*a)
print(quadratic_equation(2,5,6))
2016-09-22