List is a common data structure in many programing languages to manipulate sequence of element inside in it. In Python List is a data structure and element inside it can be any data type. such as:-Integers,floats,Strings,lists,tuple,Dictionaries,sets,booleans, and also custom objects and functions.
For Example:-
# Define various data types
integer_value = 4
float_value = 3.14
complex_value = 3 + 4j
string_value = "Hello, Kaniyam!"
list_value = [1, 2, 3]
tuple_value = (4, 5, 6)
dictionary_value = {"name": "Kaniyam Foundation", "Date_of_birth": "2012-01-01", "Age_as_at_2024": 12}
set_value = {7, 8, 9}
frozenset_value = frozenset([10, 11, 12])
boolean_value = True
bytes_value = b"kaniyam"
bytearray_value = bytearray(b"Kaniyam")
memoryview_value = memoryview(b"Kaniyam")
def function():
return "Kaniyam"
lambda_value = lambda x: x + 1
class MyClass:
pass
my_object = MyClass()
# Create a list containing all these elements
List_of_data_types_which_can_be_included_in_the_List_data_structure_in_python = [
integer_value, float_value, complex_value, string_value, list_value, tuple_value, dictionary_value, set_value, frozenset_value,
boolean_value, bytes_value, bytearray_value, memoryview_value, function, lambda_value, my_object
]
# Print the list
print(List_of_data_types_which_can_be_included_in_the_List_data_structure_in_python)
Output:
[4, 3.14, (3+4j), 'Hello, Kaniyam!', [1, 2, 3], (4, 5, 6), {'name': 'Kaniyam Foundation', 'Date_of_birth': '2012-01-01', 'Age_as_at_2024': 12}, {8, 9, 7}, frozenset({10, 11, 12}), True, b'kaniyam', bytearray(b'Kaniyam'), <memory at 0x7e608fedc1c0>, <function function at 0x7e60c4dc67a0>, <function <lambda> at 0x7e60c4dc6cb0>, <__main__.MyClass object at 0x7e60c4dea6b0>]
Top comments (0)