<jupyter_start><jupyter_text>Tuples<jupyter_code>x = ('Rama', "Krishna", "Laxminarsimha")
x
print(x)
y = ['Rama', "Krishna", "Laxminarsimha" ]
y
print(y)
x[2]
y[2]
z = (1,2,3,5,8)
z
sum(z)
max(z)
print(max(z))
list = ['a','b','c']
list.pop()
t = tuple()
dir(tuple)
(x,y) = (4, 'fred')

print(x)

print(y)
(a,b) = (99,98)

print(a)

print(b)
# the items method in dictionaries returns a LIST of TUPLES

d = dict()
d['csev'] = 2
d['cwen'] = 4

for (k,v) in d.items():
    print(k,v)
    
    
tups = d.items()
print(tups)

(0,1,2) < (0,2,2)
(0,1,200000) < (0,3,4)
('Jones', 'Sally') < ('Jones', 'Satny')
('Jones','Sally') > ('Adams','Sam')
(0,1,200000) < (0,0,3)
d = {'a':10, 'b':1, 'c': 22}

t = d.items()
t
t.sort()
t
d = {'a':10, 'c':22, 'b':1}
d.items()
t = sorted(d.items())
t
for k,v in sorted(d.items()):
    print(k,v)
for k,v in t:
    print(k,v)
c = {'a':10, 'b':1, 'c':22}
tmp = list()
for k,v in c.items():
    tmp.append((v,k))
print(tmp)
c = {'a':10, 'b':1, 'c':22}
print(sorted((v,k) for k,v in c.items()))
fhand = open('polarity_pos.txt')
counts = dict()
for line in fhand:
    words = line.split()
    for word in words:
        counts[word] = counts.get(word, 0) + 1
        
lst = list()
for key,val in counts.items():
    lst.append((val,key))
    
lst.sort(reverse=True)

for var, key in lst[:10]:
    print(key,val)

fhand = open('polarity_pos.txt')
counts = dict()
for line in fhand:
    words = line.split()
    for word in words:
        counts[word] = counts.get(word, 0) + 1
        
print(sorted((v,k) for k,v in counts.items()))

# Shorter version

c = {'a': 10, 'b':1, 'c':22}

print(sorted((v,k) for k,v in c.items()))<jupyter_output>[(1, 'b'), (10, 'a'), (22, 'c')]
{'fraction_non_alphanumeric': 0.25073746312684364, 'fraction_numerical': 0.04601769911504425, 'mean_word_length': 3.790960451977401, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '135761', 'license': 'Apache-2.0', 'n_tokens_mistral': 855, 'n_tokens_neox': 816, 'n_words': 192, 'path': 'Tuples.ipynb', 'repo_name': 'sudheer1710/Remaining-Files', 'size': '1695'}