if a==0:
if b==0:
return "There is no answer for this equation"
else:
return -c/b
else:
dirt=pow(b,2)-4*a*c
if dirt<0:
return "There is no answer for this equation"
elif dirt==0:
return -b/(2*a)
else :
return (-b+ math.sqrt(dirt))/(2*a),(-b-math.sqrt(dirt))/(2*a)
if b==0:
return "There is no answer for this equation"
else:
return -c/b
else:
dirt=pow(b,2)-4*a*c
if dirt<0:
return "There is no answer for this equation"
elif dirt==0:
return -b/(2*a)
else :
return (-b+ math.sqrt(dirt))/(2*a),(-b-math.sqrt(dirt))/(2*a)
2018-09-12
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
2018-09-12
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2==0:
continue
sum+=x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2==0:
continue
sum+=x
print sum
2018-09-12
sum = 0
x = 1
n = 1
while True:
sum+=x
x=2**n
n=n+1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum+=x
x=2**n
n=n+1
if n>20:
break
print sum
2018-09-12
使用2的n次方规律
sum = 0
x = 1
n = 1
while True:
if n > 20:
break
sum = sum + x
x = 2 ** n
n = n + 1
print sum
sum = 0
x = 1
n = 1
while True:
if n > 20:
break
sum = sum + x
x = 2 ** n
n = n + 1
print sum
2018-09-12
这个最主要的就是思路了 其实本身move()并没有太大的意义 是我们去定义它的内容和思路 3个位置 我们去想成3个盒子也可以 先从1号盒子当中拿出n-1个球 放到2号盒子 这是一步 再把剩下的一个球放到3号位置 这是第二步 然后把放到2号盒子里面的球 再放进去1号盒子 这是第三步 再把 放进1号盒子的球放回进去3号盒子 这是第四步 以此就可以实现所有的球都是最终通过1号放到3号 而2号只是一个第三方 基本上就是这样子
2018-09-12
sum = 0
x = 1
n = 1
while True:
sum=sum+(x+1)**(n-1)
n+=1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum=sum+(x+1)**(n-1)
n+=1
if n>20:
break
print sum
2018-09-11
sum = 0
x = 1
while (x<100):
if(x%2!=0):
sum+=x
x+=1
print (sum)
x = 1
while (x<100):
if(x%2!=0):
sum+=x
x+=1
print (sum)
2018-09-11
sum = 0
for a in range(1,101):
if a%2 == 0:
continue
sum+=a
print (sum)
for a in range(1,101):
if a%2 == 0:
continue
sum+=a
print (sum)
2018-09-10
sum = 0
x = 1
n = 1
while True:
sum+=x
x*=2
n+=1
if n > 20:
break
print (sum)
x = 1
n = 1
while True:
sum+=x
x*=2
n+=1
if n > 20:
break
print (sum)
2018-09-10
大神看看,错在哪
sum = 0
a = 1
for a in range(1,100):
sum+=a
a+=2
print (sum)
sum = 0
a = 1
for a in range(1,100):
sum+=a
a+=2
print (sum)
2018-09-10
你们要这么复杂?
sum = 0
x = 1
while x < 100:
sum+=x
x+=2
print (sum)
sum = 0
x = 1
while x < 100:
sum+=x
x+=2
print (sum)
2018-09-10
#!/bin/python3
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for a in d:
print (a,d.get(a))
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for a in d:
print (a,d.get(a))
2018-09-10
for x in ['1','2','3','4','5','6','7','8','9']:
for y in ['2','3','4','5','6','7','8','9']:
if x < y:
print x + y
for y in ['2','3','4','5','6','7','8','9']:
if x < y:
print x + y
2018-09-09