sum = 0
x = 1
while x<100:
print x
x=x+2
sum=sum+x
print sum
x = 1
while x<100:
print x
x=x+2
sum=sum+x
print sum
2020-02-05
import math
def quadratic_equation(a, b, c):
m=b*b-4*a*c
if m<0:
print('data error')
return
else:
n=math.sqrt(m)
x1=(-b+n)/(2*a)
x2=(-b-n)/(2*a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
m=b*b-4*a*c
if m<0:
print('data error')
return
else:
n=math.sqrt(m)
x1=(-b+n)/(2*a)
x2=(-b-n)/(2*a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2020-02-01
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:'+str(d['Adam'])
print 'Lisa:'+str(d.get('Lisa'))
print 'Bart:'+str(d.get('Bart'))
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:'+str(d['Adam'])
print 'Lisa:'+str(d.get('Lisa'))
print 'Bart:'+str(d.get('Bart'))
2020-01-31
简简单单地处理。
for x in range(1,10):
for y in range(x+1,10):
print x*10+y
range(x)=range(0,x)=[0,1,2,3,...,x-1]
for x in range(1,10):
for y in range(x+1,10):
print x*10+y
range(x)=range(0,x)=[0,1,2,3,...,x-1]
2020-01-31
for i in range(1,10):
for j in range(i+1,10):
print i*10+j
借鉴了楼下的思想
for j in range(i+1,10):
print i*10+j
借鉴了楼下的思想
2020-01-30