import math
def quadratic_equation(a, b, c):
y = math.sqrt(b * b - 4 * a * c)
x1 = (-b + y) / (2 * a)
x2 = (-b - y) / (2 * a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
y = math.sqrt(b * b - 4 * a * c)
x1 = (-b + y) / (2 * a)
x2 = (-b - y) / (2 * a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2015-06-30
sum = 0
x = 0
while True:
x = x + 1
if x%2==0:
continue
if x > 100:
break
sum=sum+x
print sum
x = 0
while True:
x = x + 1
if x%2==0:
continue
if x > 100:
break
sum=sum+x
print sum
2015-06-30
def square_of_sum(L):
return sum([x**2 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**2 for x in L])
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2015-06-30
for x in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
for y in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]:
if x < y :
print x * 10+y
为什么报错呢?
for y in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]:
if x < y :
print x * 10+y
为什么报错呢?
2015-06-29
正是因为用()定义单元素的tuple有歧义,所以 Python 规定,单元素 tuple 要多加一个逗号“,”,这样就避免了歧义
2015-06-29
grade = ['Adam', 95.5, 'Lisa', 85, 'Bart',59]
print grade
print grade
2015-06-29
最新回答 / mark_fork
是知道呢,不过教程很好,至少了解了与svn的区别,什么是暂存区,工作区,以及remote origin repository(coding.net,github).
2015-06-28