Move History

Fork Selected
  • Code
    from random import getrandbits
    
    def RandomBool():
        return bool(getrandbits(1))
    Test Cases
    import codewars_test as test
    from solution import RandomBool
    
    @test.describe("Example")
    def test_group():
        @test.it("test case")
        def test_case():
            test.assert_equals(RandomBool() in [True, False], True)
    
  • Code
    • from random import getrandbits
    • class RandomBool(object):
    • def __init__(self):
    • self.b = bool(getrandbits(1))
    • def __repr__(self):
    • return f'{self.b}'
    • def RandomBool():
    • return bool(getrandbits(1))
    Test Cases
    • import codewars_test as test
    • from solution import RandomBool
    • @test.describe("Example")
    • def test_group():
    • @test.it("test case")
    • def test_case():
    • test.assert_equals(RandomBool().b in [True, False], True)
    • test.assert_equals(RandomBool() in [True, False], True)