Junior — Middle
Can you explain what a structured data type for storing object properties is?
sobes.tech AI
Answer from AI
In Python, a structured data type for storing object properties is usually represented by classes and dictionaries (dict). A class allows defining a set of attributes and methods that describe the properties and behavior of an object. For example:
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
p = Person('Ivan', 30)
print(p.name) # Ivan
Dictionaries are also often used for dynamic property storage:
obj = {'name': 'Ivan', 'age': 30}
print(obj['name']) # Ivan
Thus, a structured data type is a way to organize related data (properties) within a single object for easy access and management.