T1:Brief Introduction to Data Structures in Python List, Tuple Set and Dictionary
HTML-код
- Опубликовано: 27 дек 2024
- """
Below is the code used in the video.
Brief Introduction to Data Structures in Python List, Tuple Set and Dictionary
@author: ambi
copyright = "Copyright (C) Ambi"
"""
#Brief Introduction to Data Structures in Python List, Tuple Set and Dictionary
#List
data=["Australia","UK","USA","Japan"]
#Tuple, immutable, value can not be changed afterwards
data=("Australia","UK","USA","Japan")
#Set, duplicates not allowed
data={"Australia","UK","USA","Japan","UK"}
#Dictionary, key value pair
data={"Australia":"Canberra","UK":"London","USA":"Washington, D.C.","Japan":"Tokyo"}
print(len(data))
for item in data:
print(item)
#For dictionary to access both the key and value
#for item in data:
print(item, data[item])