In a cube, all sides are of equal length. You would only need the length of one side.
class cube: def __init__(self, a): self.a = a def volume(self): return self.a**3
- class cube:
def __init__(self, a, b, c):- def __init__(self, a):
- self.a = a
self.b = bself.c = c- def volume(self):
return self.a*self.b*self.c- return self.a**3
import codewars_test as test # TODO Write tests from solution import cube # 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).volume(), 343) test.assert_equals(cube(5).volume(), 125) test.assert_equals(cube(3).volume(), 27)
- import codewars_test as test
- # TODO Write tests
- from solution import cube
- # 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(cube(7).volume(), 343)
- test.assert_equals(cube(5).volume(), 125)
- test.assert_equals(cube(3).volume(), 27)