A cube consists of squares. You would only need one side's length.
class cuboid: def __init__(self, a, b, c): self.a = a self.b = b self.c = c def volume(self): return self.a*self.b*self.c
class cube:- class cuboid:
- def __init__(self, a, b, c):
- self.a = a
- self.b = b
- self.c = c
- def volume(self):
- return self.a*self.b*self.c
import codewars_test as test # TODO Write tests from solution import cuboid # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(cuboid(7, 9, 4).volume(), 252) test.assert_equals(cuboid(5, 12, 7).volume(), 420) test.assert_equals(cuboid(3, 7, 49).volume(), 1029)
- import codewars_test as test
- # TODO Write tests
from solution import cube- from solution import cuboid
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
test.assert_equals(cube(7, 9, 4).volume(), 252)test.assert_equals(cube(5, 12, 7).volume(), 420)test.assert_equals(cube(3, 7, 49).volume(), 1029)- test.assert_equals(cuboid(7, 9, 4).volume(), 252)
- test.assert_equals(cuboid(5, 12, 7).volume(), 420)
- test.assert_equals(cuboid(3, 7, 49).volume(), 1029)