import math
def quadratic_equation(a, b, c):
d=b*b-4*a*c
if a==0:
return -c/b
elif d<0:
return 'the equation has no real roots'
elif d==0:
return -b/(2*a)
elif d>0:
return ((math.sqrt(d) - b ) / (2 * a)) , ((-math.sqrt(d) - b ) / (2 * a))
def quadratic_equation(a, b, c):
d=b*b-4*a*c
if a==0:
return -c/b
elif d<0:
return 'the equation has no real roots'
elif d==0:
return -b/(2*a)
elif d>0:
return ((math.sqrt(d) - b ) / (2 * a)) , ((-math.sqrt(d) - b ) / (2 * a))
2016-10-15
print [int(x+y+z) for x in '123456789' for y in '0123456789' for z in '123456789' if x==z]
2016-10-15
最赞回答 / lhugh
python hello.py或者 先敲 python+空格 然后把文件拖进命令提示符内 最后回车就好(另外:脚本第一行一定要写上 #!usr/bin/python表示该脚本文件是可执行python脚本)
2016-10-15
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
for key,value in d.items():
print key,':',value
print 'average', ':', sum(d.values())*1.0/len(d)
for key,value in d.items():
print key,':',value
print 'average', ':', sum(d.values())*1.0/len(d)
2016-10-15
print [a*100+b*10+c for a in range(1,10) for b in range(0,10) for c in range(0,10) if a==c]
2016-10-15
print ' Python was started in 1989 by "Guido".\n Python is free and easy to learn.' 直接通过
2016-10-15