<jupyter_start><jupyter_text>1 Reverse A String<jupyter_code>string = 'Hello all!'
print(string)
backward = string[::-1]
print(backward)<jupyter_output>!lla olleH<jupyter_text>2 Dims as variables<jupyter_code>array = [5, 10, 15, 20]
five, ten, fift, twent = array

print(five)
print(ten)
print(fift)
print(twent)<jupyter_output>5
10
15
20<jupyter_text>3 Itertools<jupyter_code>c = [[1, 2], [3, 4], [5, 6]]
# Let's convert this matrix to a 1 dimensional list.
import itertools as it
newlist = list(it.chain.from_iterable(c))
print(c)

print(newlist)<jupyter_output>[1, 2, 3, 4, 5, 6]<jupyter_text>4 Intelligent Unpacking<jupyter_code>a, *b, c = [1, 2, 3, 4, 5]
print(a)
print(b)
print(c)<jupyter_output>1
[2, 3, 4]
5<jupyter_text>5 Enumerate<jupyter_code>for i,w in enumerate(array):
    print(i,w)<jupyter_output>0 5
1 10
2 15
3 20<jupyter_text>6 Name Sliceshttps://www.programiz.com/python-programming/methods/built-in/slice<jupyter_code>a = [0, 1, 2, 3, 4, 5]
LASTTHREE = slice(-3, None)
slice(-3, None, None)
print(LASTTHREE)
print(a[LASTTHREE])<jupyter_output>slice(-3, None, None)
[3, 4, 5]<jupyter_text>7 Group Adjacent Lists<jupyter_code>a = [1, 2, 3, 4, 5, 6]  
group_adjacent = lambda a, k: zip(*([iter(a)] * k)) 
group_adjacent(a, 3) [(1, 2, 3), (4, 5, 6)] 
group_adjacent(a, 2) [(1, 2), (3, 4), (5, 6)] 
group_adjacent(a, 1)<jupyter_output><empty_output><jupyter_text>8 next() iteration for generators<jupyter_code>array1 = [5, 10, 15, 20]
array2 = (x ** 2 for x in range(10))
counter = 0
for i in array1:
# This code wouldn't work because 'i' is not in array2.
   # i = array2[i]
    i = array2[counter]
#    ^^^ This code would because we are accessing the position of i<jupyter_output><empty_output><jupyter_text>9 Counter<jupyter_code>import collections 

A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7]) 
A = Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1}) 
A.most_common(1) [(3, 4)] 
A.most_common(3) [(3, 4), (1, 2), (2, 2)]<jupyter_output><empty_output><jupyter_text>10 Dequeue<jupyter_code>import collections
Q = collections.deque() 
Q.append(1) 
Q.appendleft(2) 
Q.extend([3, 4]) 
Q.extendleft([5, 6]) 
Q.pop()
Q.popleft()
Q.rotate(3) 
Q.rotate(-3)
print(Q)<jupyter_output>deque([5, 2, 1, 3])
{'fraction_non_alphanumeric': 0.1780269058295964, 'fraction_numerical': 0.07085201793721974, 'mean_word_length': 5.679640718562874, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '648162', 'license': 'MIT', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1003, 'n_words': 245, 'path': 'Python_tips.ipynb', 'repo_name': 'krivolapov/Python_tips', 'size': '2230'}