Professional Documents
Culture Documents
Natural Language Processing - 3
Natural Language Processing - 3
DICTIONARY
Luvia Friska Narulita
List
append()
list_beverages = [
List can also have more than one dimension [“Coffee”, “Milk”, ”Tea”],
[“Apple Juice”, “Orange Juice”, ”Watermelon Juice”],
Multi dimensional list is usually used for [“Coffee Ice”, “Mix Fruit Ice”, “Es Teler”]
]
storing the complex data structure, such as
table, matrix, graph, tree, etc
DICTIONARY
Dictionary?
numbers = {‘one’: 1, ‘two’ : 2, ‘three’: 3}
>>>print(numbers[‘one’])
1
numbers[‘one’] = ‘satu’
>>>print(numbers)
‘one’ in numbers
‘two’ not in numbers
dict() constructor Looping Techniques
dict(sape=4139, guido=4127)
for k,v in knights.items():
print(k,v)
Exercise
■ a = ['1', '13b', 'aa1', 1.32, 22.1, 2.34]
Gunakan slicing list
■ a = [1.32, 22.1, 2.34]
b = ['1', '13b', 'aa1']
c = [3, 40, 100]
Expected output : [ [1.32, 22.1, 2.34], [3, 40, 100], ['1', '13b', 'aa1'] ]
■ a = [
[5, 9, 8],
[0, 0, 6]
]
Expected Output :
[ [5, 9, 10], [11, 0, 6] ]