Junior — Middle
What standard built-in functions does Python provide for working with data and data types?
sobes.tech AI
Answer from AI
Python provides many built-in functions for working with data and data types. Here are some of the main ones:
type(obj)— returns the type of an object.len(obj)— the length of an object (list, string, dictionary, etc.).int(),float(),str()— type conversions.list(),dict(),set(),tuple()— create corresponding collections.isinstance(obj, classinfo)— checks if an object belongs to a specific type.sorted(iterable)— returns a sorted list.sum(iterable)— sum of elements.min(),max()— minimum and maximum values.enumerate(iterable)— returns pairs of index and value.zip(*iterables)— combines multiple iterable objects.
Example:
numbers = [1, 3, 2]
print(sorted(numbers)) # [1, 2, 3]
print(sum(numbers)) # 6
print(isinstance(numbers, list)) # True