print [x for x in range(100,1000) if str(x)[0] == str(x)[2]]
我的思路完全不一样,,。
我的思路完全不一样,,。
2015-08-24
L = [75, 92, 59, 68]
sum = 0.0
for x in L:
sum = sum + x
print sum / 4
sum = 0.0
for x in L:
sum = sum + x
print sum / 4
2015-08-24
说数学是硬伤的,百度总会吧,把搜索xdy的能力的1/10就可以了:https://zh.wikipedia.org/wiki/%E4%B8%80%E5%85%83%E4%BA%8C%E6%AC%A1%E6%96%B9%E7%A8%8B
2015-08-24
t = ('a', 'b', ('A', 'B'))
print t
print t
2015-08-24
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop()
print L
L.pop(2)
L.pop()
print L
2015-08-24
import math
def quadratic_equation(a, b, c):
if b*b-4*a*c < 0:
return 'No Solution'
else:
x1 = (-b+math.sqrt(b*b-4*a*c))/(2*a)
x2 = (-b-math.sqrt(b*b-4*a*c))/(2*a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
if b*b-4*a*c < 0:
return 'No Solution'
else:
x1 = (-b+math.sqrt(b*b-4*a*c))/(2*a)
x2 = (-b-math.sqrt(b*b-4*a*c))/(2*a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2015-08-24
import math
def quadratic_equation(a, b, c):
if b*b-4*a*c < 0:
return 'No Solution'
else:
x1 = -b+math.sqrt(b*b-4*a*c)
x2 = -b-math.sqrt(b*b-4*a*c)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
if b*b-4*a*c < 0:
return 'No Solution'
else:
x1 = -b+math.sqrt(b*b-4*a*c)
x2 = -b-math.sqrt(b*b-4*a*c)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2015-08-24
def square_of_sum(L):
return sum([x*x for x in L])
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
return sum([x*x for x in L])
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2015-08-24
代码检查有缺陷,如果只输入'adam','bart'就会成功,与题目意思不符
2015-08-24
print r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''
Whether it's nobler in the mind to suffer.'''
2015-08-23