最赞回答 / 我要做大神
不能用=,应该用==。while x=2*n的时候会把x=2*n执行之后返回true表示已经赋值结束表示,此时while就一直是true,不会出现false,所以应该使用x==2*n表示需要判断
2016-10-04
正解
print r'''"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'''
加单引号
print ('''\'"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.\'''')
'"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'
print r'''"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'''
加单引号
print ('''\'"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.\'''')
'"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'
2016-10-04
最新回答 / 知而学
没毛病!对输入做控制就好,加上if not isinstance(n,int): raise TypeError('Bad........')if n<=0: raise ValueError('Bad.......')
2016-10-04
import math
def quadratic_equation(a, b, c):
d = b*b - 4*a*c
if(d > 0):
x_1 = (-b + math.sqrt(d)) / (2*a)
x_2 = (-b - math.sqrt(d)) / (2*a)
return x_1, x_2
elif(d == 0):
x = - b/2*a
return x
else:
return None
def quadratic_equation(a, b, c):
d = b*b - 4*a*c
if(d > 0):
x_1 = (-b + math.sqrt(d)) / (2*a)
x_2 = (-b - math.sqrt(d)) / (2*a)
return x_1, x_2
elif(d == 0):
x = - b/2*a
return x
else:
return None
2016-10-03