<jupyter_start><jupyter_text>Dictionaries<jupyter_code>myDict = {}
myDict = {1:'apple',2:'ball'}
myDict[1]
myDict={'bill':'anand','don':'nagarjuna','gurram':'arjun'}
myDict['gurram']
Dict={'name':'David',1:[4,22,6]}  # Mixed keys
purse = dict()
purse['Name'] = 'Shaktikanth'
purse['Age'] = 28
purse['Type'] = 'Leather'
purse
print(purse)
purse['Age']=purse['Age']+5
print(purse)
purse['Name'] = purse['Name'] + ' Karthik'
print(purse)
purse['Age'] = 29    #Override
print(purse)
myDict = {'name':'john',1:[2,4,3]}  # Dictionary with mixed keys
myDict = dict([(1,'apple'),(2,'ball')])
myDict
ccc = dict()
ccc['csev'] = 1
ccc['cwen'] = 1
print (ccc)
ccc['cwen'] = ccc['cwen']+1
print(ccc)
ccc = dict()
print(ccc['csev'])
print('csev' in ccc)
counts = dict()
names = ['csev','cwen','csev','zqian','cwen']
for name in names:
    if name not in counts:
        counts[name] = 1
    else:
        counts[name] = counts[name]+1
print(counts)
if name in counts:
    x = counts[name]
else:
    x = 0
    
    
x = counts.get(name, 0)

#can use get() and provide a default value of zero when the key is not yet in the dictionary and just add one.

counts = dict()
names = ['csev','cwen','csev','zqian','cwen']
for name in names:
    counts[name] = counts.get(name, 0) + 1
print(counts)
counts = dict()
print('Enter a line of text:')
line = input('')

words = line.split()

print('Words:'), words

print('Counting...')
for word in words:
    counts[word] = counts.get(word,0) + 1
print('Counts'), counts
counts = {'chuck':1,'fred':42,'jan':100}
for key in counts:
    print(key, counts[key])



name= input('Enter file:')
handle = open(name)
text = handle.read()
words = text.split()
counts = dict()
for word in words:
    counts[word] = counts.get(word,0) + 1
    bigcount = None
    bigword = None
for word,count in counts.items():
    if bigcount is None or count > bigcount:
        bigword = word
        bigcount = count
print(bigword, bigcount)
myDict = {1:'apple',2:'ball'}
myDict[1]                                # Accessing Dictionary
myDict = {1:'apple',2:'ball'}
len(myDict)                          # Length of the Dictionary # No.of Key value pairs
myDict = {1:'apple',2:'ball'}
myDict.keys()
myDict = {1:'apple',2:'ball'}
myDict.values()
myDict = {1:'apple',2:'ball'}
myDict.items()                  # All items inside the Dictionary
myDict.get(1)                   # Getting the value for key
myDict.update({3:'cat'})            #  Updating new key value into the Dictionary
myDict
myDict.pop(3)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1833267483208218, 'fraction_numerical': 0.020545239035954167, 'mean_word_length': 3.888030888030888, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '93852', 'license': 'Apache-2.0', 'n_tokens_mistral': 973, 'n_tokens_neox': 922, 'n_words': 238, 'path': 'My third notebook dictionaries.ipynb', 'repo_name': 'sudheer1710/Remaining-Files', 'size': '2531'}