x1=1
d=3
n=1
s=0
while n<=100:
s=x1+3*(n-1)+s
n=n+1
print s
d=3
n=1
s=0
while n<=100:
s=x1+3*(n-1)+s
n=n+1
print s
2015-07-22
x1=1
d=3
n=1
s=0
if n>=100:
print s
else:
s=x1+3*(n-1)+s
n=n+1
d=3
n=1
s=0
if n>=100:
print s
else:
s=x1+3*(n-1)+s
n=n+1
2015-07-22
import math
def quadratic_equation(a, b, c):
if b*b-4*a*c>0:
x1=(-b+math.sqrt(b*b-4*a*c))/2*a
x2=(-b-math.sqrt(b*b-4*a*c))/2*a
else:
print 'error'
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:
x1=(-b+math.sqrt(b*b-4*a*c))/2*a
x2=(-b-math.sqrt(b*b-4*a*c))/2*a
else:
print 'error'
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2015-07-20
代码仅供参考。
for x in range(1,10):
for y in range(10):
if x < y:
print x * 10 + y
for x in range(1,10):
for y in range(10):
if x < y:
print x * 10 + y
2015-07-20