Light Mode
Dark Mode
Help

Why result fail?

My code:

def checkio(*args): print ("args: ", args)

if len(args) == 0:
    print ("empty")
    result = 0
elif len(args) == 1:
    print ("one element")
    result = args[0]
else:
    maximum = max(args)
    minimum = min(args)    
    print ("maximum: ", maximum, ' minimum: ', minimum)
    result = abs(maximum - minimum)

print ("result: ", result)    
return result

Result

args: (1, 2, 3)

maximum: 3 minimum: 1

result: 2

args: (5, -5)

maximum: 5 minimum: -5

result: 10

args: (10.2, -2.2, 0, 1.1, 0.5)

maximum: 10.2 minimum: -2.2

result: 12.399999999999999

args: ()

empty

result: 0

CheckResult

Your result: -0.07

Right result: 0

Fail: checkio(-0.07)

Created: Jan. 11, 2016, 1:38 p.m.
Updated: Jan. 12, 2016, 8:16 a.m.
0
5
User avatar
DarkHo66it