Ad

Just realized bug in the problem. If there are 2 negative lengths and 1 positive lengths, it will still return a positive integer. Thus, we test if the cube is valid in the first place.

Code
Diff
  • def kube(l,w,h):
        if l < 0 or w < 0 or h < 0:
            return "Invalid Cube"
        else:
            return l * w * h
    
    • kube = lambda l, w, h: max(l * w * h, 0)
    • def kube(l,w,h):
    • if l < 0 or w < 0 or h < 0:
    • return "Invalid Cube"
    • else:
    • return l * w * h
Code
Diff
  • def pepito(chiqui):
        return 1
    • def pepito(chiqui):
    • return chiqui
    • return 1

Testing for negative numbers

Code
Diff
  • def kube(x, y, z):
        if x * y * z > 0:
            return x*y*z
        if x * y * z < 0:
            return 0
    • def kube(x, y, z):
    • #your code here
    • return x*y*z
    • #return 0
    • if x * y * z > 0:
    • return x*y*z
    • if x * y * z < 0:
    • return 0