<jupyter_start><jupyter_text>Week 06, Assignment 03: List Comprehension One liners with great powerIn this lesson we will be understanding list comprehension and why they are useful to us  Objective 1: A refresherGive a brief explanation of what a ternary expression does.  Objective 2: A simple redoExecute the code in the cell below, then rewrite the program as a list comprehension in the cell below it to produce the same output.<jupyter_code>alphabet = []
for char_code in range (97,123):
    alphabet.append(chr(char_code))
print(alphabet)<jupyter_output>['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']<jupyter_text>Objective 3: A little more complicated redoIn the cell below is another program that creates a list of data, but using list comprehension this can be done in less lines of code. In the cell below it rewrite the program to do so.<jupyter_code>from random import choice
toppings = {"cheese":"animal product","ham":"meat","bacon":"meat",
            "tomato":"vegetable","feta":"animal product",
            "mushrooms":"vegetable","herbs":"vegetable",
            "pineapple":"vegetable","chicken":"meat",
            "anchovey":"animal product"}
meats = []
animal_prods = []
vegetables = []
for k,v in toppings.items():
    if v == "animal product": 
        animal_prods.append(k)
    elif v == "meat": 
        meats.append(k)
    elif v == "vegetable":
        vegetables.append(k)

print(animal_prods)
print(meats)
print(vegetables)

one_one_one_pizza = []
for i in range (10):
    topping1 = choice(meats)
    topping2 = choice(animal_prods)
    topping3 = choice(vegetables)
    one_one_one_pizza.append((topping1,topping2,topping3))
print (one_one_one_pizza)
# Better list creation here!<jupyter_output><empty_output><jupyter_text>Objective 3: Comprehending unlimited powerThe data belows shows the salary of employees with the respective number hours completed and their hourly wage. Create a list of the total number of money that needs to be paid out per person. The data should be a form a tuple with two elements, the name of the person and the total amount due to them.<jupyter_code>person = ["John","Jill","Olga","Bobby","Winston"]
hourly = [15.99,10.25,19.50,13.59,60.0]
worked = [140,200,125,99,100]


# [(John, 2238.60), (Jill, ..., etc...]<jupyter_output><empty_output><jupyter_text>Objective 4: Classify the payrollsUsing the list above classify each person's wage bracket into the following criteria:* 0-2000: Low income* 2000-4000: Medium income* 4000+: High incomeCreate a list with a printable statement that reads "Person is has a Low income of XXXX".<jupyter_code># result should be: ["John has a Medium income of 2238.0","... etc]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12652329749103944, 'fraction_numerical': 0.02974910394265233, 'mean_word_length': 4.754639175257732, 'pattern_counts': {'":': 13, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '359906', 'license': 'MIT', 'n_tokens_mistral': 973, 'n_tokens_neox': 886, 'n_words': 318, 'path': 'python/Assignment_Two/Assignment 2.5.1_ListComprehensions.ipynb', 'repo_name': 'Vattenkruka/Python_Short_Course', 'size': '2790'}