<jupyter_start><jupyter_text>Comprehensions  List Comprehensions<jupyter_code>words = 'I just like marvel universe movies which are so amazing'.split()
words
[len(word) for word in words]
#finding factorial of len of each item from 1 to 19
from math import factorial
f = [str(factorial(x)) for x in range(20)]
f
f = [ len(str(factorial(x))) for x in range(20)]
f<jupyter_output><empty_output><jupyter_text>Set Comprehensions<jupyter_code>s = {len(str(factorial(x))) for x in range(20)}
s<jupyter_output><empty_output><jupyter_text>Dictionary Comprehensions<jupyter_code>country_to_capital = {
    'Myanmar':'Yangon',
    'Singapore':'Singapore',
    'Thailand':'Bangkok'}
capital_to_country = {capital:country for country,capital in country_to_capital.items()}
capital_to_country<jupyter_output><empty_output><jupyter_text>-------------<jupyter_code>words = ['hi', 'hello', 'foxtail', 'hotel']
{x[0]:x for x in words}<jupyter_output><empty_output><jupyter_text>Complex Expressions<jupyter_code>import os
import glob

file_sizes = {os.path.realpath(p):os.stat(p).st_size for p in glob.glob('*.py')}
file_sizes<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14323374340949033, 'fraction_numerical': 0.008787346221441126, 'mean_word_length': 7.694656488549619, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '442668', 'license': 'MIT', 'n_tokens_mistral': 440, 'n_tokens_neox': 415, 'n_words': 86, 'path': '06.Core Python - Getting Started/09.List Set Dictionary Filtering Comprehensions.ipynb', 'repo_name': 'ptyadana/python-dojo', 'size': '1138'}