Collection-Literals

Tue 09 December 2025
#  Collection literals in Python
#  List literals
address = ['Scientech Easy', 'Joraphatak Road', 'Dhanbad']
print(address)
['Scientech Easy', 'Joraphatak Road', 'Dhanbad']
num = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(num)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
mix=[1,1,2,3,'jerin',0.8,-1]
print(mix)
[1, 1, 2, 3, 'jerin', 0.8, -1]
#  Dictionary Literals
fruits_dict = {
    'a': 'apple',
    'o': 'orange',
    'b': 'banana'
}
print(fruits_dict)
{'a': 'apple', 'o': 'orange', 'b': 'banana'}
info_dict = {
    "name":"jerin",
    "age":23,
    "studies":"python"
}
print(info_dict)
{'name': 'jerin', 'age': 23, 'studies': 'python'}
#  Tuple Literals
even_numbers = (2, 4, 6, 8, 10, 12)
vowels = ('a','e','i','o','u')
direction = ('North', 'South', 'East', 'West')
print(even_numbers)
(2, 4, 6, 8, 10, 12)

print(vowels)
('a', 'e', 'i', 'o', 'u')
print(direction)
('North', 'South', 'East', 'West')
print(even_numbers)
print(vowels)
print(direction)
(2, 4, 6, 8, 10, 12)
('a', 'e', 'i', 'o', 'u')
('North', 'South', 'East', 'West')
print(type(even_numbers))
print(type(vowels))
print(type(direction))
<class 'tuple'>
<class 'tuple'>
<class 'tuple'>
print(type(even_numbers))
<class 'tuple'>
print(type(vowels))
<class 'tuple'>
print(type(direction))
<class 'tuple'>
# Set Literals
fruits = {'Apple', 'Mango', 'Banana', 'Orange', 'Grape'}
print(fruits)
{'Banana', 'Grape', 'Orange', 'Apple', 'Mango'}
name = {"jerin","jerin","anbu","jeno","ram"}
print(name)
{'jeno', 'jerin', 'ram', 'anbu'}
print(name)
{'jeno', 'jerin', 'ram', 'anbu'}


Score: 30

Category: Python basics