<jupyter_start><jupyter_text>**basic code**<jupyter_code>alphabet = ["a","b","c","d","e"]
result = ""

for s in alphabet:
    result += s
print(result)<jupyter_output>abcde<jupyter_text>**pythonic code**<jupyter_code>alphabet = ["a","b","c","d","e"]
result = "".join(alphabet)
print(result)<jupyter_output>abcde<jupyter_text>**split string**<jupyter_code>items = 'zero one two three'.split()
print(items)
example = 'python,c++,java'
print(example.split(","))<jupyter_output>['python', 'c++', 'java']<jupyter_text>**split string and unpacking**<jupyter_code>example = 'python, c++, java'
a,b,c = example.split(",")
print(a,b,c)<jupyter_output>python  c++  java<jupyter_text>**for loop + append**<jupyter_code>result = []

for i in range(10):
    result.append(i)
print(result)<jupyter_output>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]<jupyter_text>**list Complrehension**<jupyter_code>result = [i for i in range(10)]
print(result)
result = [i for i in range(10) if i % 2 == 0]
print(result)<jupyter_output>[0, 2, 4, 6, 8]<jupyter_text>**Nested For loop**<jupyter_code>word_1 = "Hello"
word_2 = "World"
result = [i+j for i in word_1 for j in word_2]
print(result)<jupyter_output>['HW', 'Ho', 'Hr', 'Hl', 'Hd', 'eW', 'eo', 'er', 'el', 'ed', 'lW', 'lo', 'lr', 'll', 'ld', 'lW', 'lo', 'lr', 'll', 'ld', 'oW', 'oo', 'or', 'ol', 'od']<jupyter_text>**Nested For loop + if**<jupyter_code>case_1 = ["A","B","C"]
case_2 = ["D","E","A"]

result = [i+j for i in case_1 for j in case_2]
print(result)
result = [i+j for i in case_1 for j in case_2 if not(i==j)]
result.sort()
print(result)<jupyter_output>['AD', 'AE', 'BA', 'BD', 'BE', 'CA', 'CD', 'CE']<jupyter_text>**split + list Comprehension**<jupyter_code>words = 'The quick brown fox jumps over the lazy dog'.split()
print(words)
stuff = [[w.upper(),w.lower(),len(w)] for w in words]

for i in stuff:
    print(i)<jupyter_output>['THE', 'the', 3]
['QUICK', 'quick', 5]
['BROWN', 'brown', 5]
['FOX', 'fox', 3]
['JUMPS', 'jumps', 5]
['OVER', 'over', 4]
['THE', 'the', 3]
['LAZY', 'lazy', 4]
['DOG', 'dog', 3]<jupyter_text>**for loop + zip**<jupyter_code>alist = ['a1','a2','a3']
blist = ['b1','b2','b3']

for a,b in zip(alist,blist):
    print(a,b)<jupyter_output>a1 b1
a2 b2
a3 b3<jupyter_text>**list comprehension + zip**<jupyter_code>a,b,c = zip((1,2,3),(10,20,30),(100,200,300))
print(a,b,c)
print([sum(x) for x in zip((1,2,3),(10,20,30),(100,200,300))])<jupyter_output>[111, 222, 333]<jupyter_text>**enumerate + zip**<jupyter_code>alist = ['a1','a2','a3']
blist = ['b1','b2','b3']

for i,(a,b) in enumerate(zip(alist,blist)):
    print(i,a,b)<jupyter_output>0 a1 b1
1 a2 b2
2 a3 b3<jupyter_text>**lambda function**<jupyter_code>def f(x,y):
    return x+y
print (f(1,4))
f = lambda x,y:x+y
print(f(1,4))
f = lambda x:x/2
print(f(3))
f = lambda x:x**2
print(f(3))
print((lambda x:x+1)(5))<jupyter_output>9
6<jupyter_text>**map with lambda**<jupyter_code>ex = [1,2,3,4,5]
print(list(map(lambda x: x+x, ex)))
print((map(lambda x: x+x, ex)))
f = lambda x: x ** 2
print(map(f, ex))
for i in map(f, ex):
    print(i)<jupyter_output>1
4
9
16
25<jupyter_text>**reduce with lambda**<jupyter_code>from functools import reduce
print(reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]))
def factorial(n):
    return reduce(
            lambda x, y: x*y, range(1, n+1))
print(factorial(5))<jupyter_output>120<jupyter_text>**Asterika(*)**<jupyter_code>def asterisk_test1(a,*args):
    print(a,args)
    print(type(args))

asterisk_test1(1,2,3,4,5,6)
def asterisk_test2(a,**kargs):
    print(a,kargs)
    print(type(kargs))

asterisk_test2(1,b=2,c=3,d=4,e=5,f=6)
def asterisk_test3(a,*args):
    print(a,args[0])
    print(type(args))

asterisk_test3(1,(2,3,4,5,6))
def asterisk_test4(a,args):
    print(a,*args)
    print(type(args))

asterisk_test4(1,(2,3,4,5,6))
a, b, c = ([1,2],[3,4],[5,6])
print(a,b,c)
data = ([1,2],[3,4],[5,6])
print(*data)
for data in zip(*([1,2],[3,4],[5,6])):
    print(sum(data))<jupyter_output>9
12
{'fraction_non_alphanumeric': 0.2369538077403246, 'fraction_numerical': 0.05093632958801498, 'mean_word_length': 6.015761821366024, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, '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': '16', 'dir': 'jupyter-structured-clean-dedup', 'id': '470098', 'license': 'Apache-2.0', 'n_tokens_mistral': 1970, 'n_tokens_neox': 1866, 'n_words': 354, 'path': 'Lec1_1_Pythonic_Code.ipynb', 'repo_name': 'YeonKang/Python-for-Machine-Learning', 'size': '4005'}