2013-09-30 62 views

回答

0

你需要在底部返回true (另外请注意,对于我来说,如果东西是beginRange或endRange,我会考虑在里面,所以我会做<和>而不是< =和> =),并且那很重要......你可能想要返回真正的东西,否则就是假。 (另请注意,它应该是假/真不是假/真)

2

false应该False,并在年底返回True否则函数将返回None(默认的返回值),如果两个条件都False

def outside(testnum, beginRange, endRange): 
    if testnum <= beginRange: 
     return False 
    if testnum >= endRange: 
     return False 
    return True 

或者干脆:

def outside(testnum, beginRange, endRange): 
    return beginRange < testnum < endRange 
1

下一个简单衬里可在这里工作:

def inside(testnum, lowthreshold, highthreshold): 
    return lowthreshold <= testnum <= highthreshold 

def outside(testnum, lowthreshold, highthreshold): 
    return not (lowthreshold <= testnum <= highthreshold) 

编辑:意识到我是表明里面,不在外面。使它更清晰。

相关问题