Fundamentals
Logic
def identify_data_type(value): return __import__("inspect").currentframe().f_back.f_code.co_name.split("_")[1]
exec(f"""{NotImplemented.__str__().__doc__[727-700-20]}{bytes(help.__doc__, "u16").__repr__.__str__().lower()[40+7]}{NotImplemented.__str__().__doc__[727-700-20]}{__import__("this").s[69-2]}({bytes(1337).__str__()[0]}{exec.__doc__.__str__()[7+7+7+7+7+7+7+7+7+7+7]}{(7).__eq__(21).__eq__(False).__eq__(True).__str__()[0].lower()}{NotImplemented.__str__().__doc__[727-700-20]}{isinstance("i ran out of ideas for funny numbers", complex).__str__()[len("so im doing this to make it look like im super smart")-7*7]}("椊敤瑮晩役慤慴瑟灹㵥慬扭慤砠⠺祴数砨⸩彟敲牰彟弮獟牴彟⤨⸩灳楬⡴✢⤢㍛", "{__import__("__hello__").__str__()[4]}16")[2:])""")- def identify_data_type(value):
- return __import__("inspect").currentframe().f_back.f_code.co_name.split("_")[1]
import codewars_test as test from solution import identify_data_type @test.describe("Testing the identify_data_type function") def test_group(): @test.it("Testing for integers") def test_int(): test.assert_equals(identify_data_type(123), "int") test.assert_equals(identify_data_type(-987), "int") @test.it("Testing for floats") def test_float(): test.assert_equals(identify_data_type(12.3), "float") test.assert_equals(identify_data_type(-45.67), "float") @test.it("Testing for strings") def test_str(): test.assert_equals(identify_data_type("hello"), "str") test.assert_equals(identify_data_type("123"), "str") @test.it("Testing for lists") def test_list(): test.assert_equals(identify_data_type([1, 2, 3]), "list") test.assert_equals(identify_data_type([]), "list") @test.it("Testing for tuples") def test_tuple(): test.assert_equals(identify_data_type((1, 2, 3)), "tuple") test.assert_equals(identify_data_type(()), "tuple") @test.it("Testing for dictionaries") def test_dict(): test.assert_equals(identify_data_type({"key": "value"}), "dict") test.assert_equals(identify_data_type({}), "dict") @test.it("Testing for booleans") def test_bool(): test.assert_equals(identify_data_type(True), "bool") test.assert_equals(identify_data_type(False), "bool") @test.it("Testing for sets") def test_set(): test.assert_equals(identify_data_type(set([1, 2, 3])), "set") @test.it("Testing for functions") def test_function(): test.assert_equals(identify_data_type(lambda x: x), "function") @test.it("Testing for unknown data types") def test_unknown(): test.assert_equals(identify_data_type(...), "unknown")
- import codewars_test as test
- from solution import identify_data_type
- @test.describe("Testing the identify_data_type function")
- def test_group():
- @test.it("Testing for integers")
def test_integer():- def test_int():
- test.assert_equals(identify_data_type(123), "int")
- test.assert_equals(identify_data_type(-987), "int")
- @test.it("Testing for floats")
- def test_float():
- test.assert_equals(identify_data_type(12.3), "float")
- test.assert_equals(identify_data_type(-45.67), "float")
- @test.it("Testing for strings")
def test_string():- def test_str():
- test.assert_equals(identify_data_type("hello"), "str")
- test.assert_equals(identify_data_type("123"), "str")
- @test.it("Testing for lists")
- def test_list():
- test.assert_equals(identify_data_type([1, 2, 3]), "list")
- test.assert_equals(identify_data_type([]), "list")
- @test.it("Testing for tuples")
- def test_tuple():
- test.assert_equals(identify_data_type((1, 2, 3)), "tuple")
- test.assert_equals(identify_data_type(()), "tuple")
- @test.it("Testing for dictionaries")
def test_dictionary():- def test_dict():
- test.assert_equals(identify_data_type({"key": "value"}), "dict")
- test.assert_equals(identify_data_type({}), "dict")
- @test.it("Testing for booleans")
def test_boolean():- def test_bool():
- test.assert_equals(identify_data_type(True), "bool")
- test.assert_equals(identify_data_type(False), "bool")
- @test.it("Testing for sets")
- def test_set():
- test.assert_equals(identify_data_type(set([1, 2, 3])), "set")
- @test.it("Testing for functions")
- def test_function():
- test.assert_equals(identify_data_type(lambda x: x), "function")
- @test.it("Testing for unknown data types")
- def test_unknown():
test.assert_equals(identify_data_type(set([1, 2, 3])), "set")test.assert_equals(identify_data_type(lambda x: x), "function")- test.assert_equals(identify_data_type(...), "unknown")