What is a Set data type good for in Python?
Experience Level: Junior
Tags: Python
Answer
Sets are used to store multiple items in a single variable. The item value cannot be changed, but you an add and remove items to/from the set.
The set does not accept multiple items with the same value.
Example:
my_set = {"red", "amber", "green"}
print(my_set)
Related Python job interview questions
What is the datetime data type good for in Python?
Python JuniorWhat is bool data type good for in Python?
Python JuniorHow do you inherit one class from another class in Python?
Python JuniorWhy would you want to inherit a class for another class in Python?
Python JuniorWhat does strftime stand for in Python?
Python Junior