Type Checker
Problem Statement
Identify the types of different Python values.
Background
Python has several built-in types:
- int - integers (1, 42, -5)
- float - floating point numbers (3.14, 2.0)
- str - strings ("hello", 'world')
- bool - booleans (True, False)
- list - ordered collections ([1, 2, 3])
- dict - key-value mappings ({"a": 1})
Your Task
Write a function get_types(values) that takes a list of values and returns a list of their type names as strings.
Output Format
Return a list of type names (e.g., ["int", "str", "float"]).
Example
[42, 'hello', 3.14, True, [1,2], {'a': 1}]['int', 'str', 'float', 'bool', 'list', 'dict']
- Input:
valuesis a list of mixed Python values: a whole number, a piece of text, a decimal number, a truth value, a list and a dictionary. - Mapping: each value is replaced by the name of the built-in type it belongs to, written as text:
42is a whole number, so it becomes'int';'hello'becomes'str';3.14has a fractional part, so it becomes'float'. Truebecomes'bool'. Notice that even though a boolean can be used in arithmetic like , its own exact type is boolean, not integer.[1,2]becomes'list'and{'a': 1}becomes'dict': only the outer container is classified, its contents are never inspected.- Output: a list of strings, one per input value and in the same order,
['int', 'str', 'float', 'bool', 'list', 'dict']. Any other value works the same way, e.g. the empty value None is reported by its own type name.
Constraints
- Use type() function
- Return type name as string using name