<jupyter_start><jupyter_text>Week 1 - Homework  Working with Numbers<jupyter_code>## create a variable called sales equal to 45.3 million
## print it as "Sales totalled $45,300,000 in 2019" using f-string literal (0 decimal places)
## use thousands separator/digit group separator to make it easier to read
sales = 45_300_000
print(f"Sales equaled ${sales:,.0f} in 2019. ")
## create a variable called apple_cap equal to $1.41 trillion in scientific notation
## Print it like you did above but to no decimal places.
apple_cap = 1.41E12
print(f"${apple_cap:,.0f}")<jupyter_output>$1,410,000,000,000<jupyter_text>Working with Lists<jupyter_code>## Combine the two lists into a single list called combined_list
terms_1 = ["Bankruptcy", "Mergers", "Acquisitions"]
terms_2 = ["Short selling", "Liquidations", "Equity"]

### method 1
# combined_list = terms_1 + terms_2


### method 2
# terms_1.extend(terms_2)
# combined_list = terms_1

# method 3 (PREFERRED)
combined_list = [*terms_1, *terms_2]

## show the new list:
combined_list<jupyter_output><empty_output><jupyter_text>Working with List of Dictionaries Create a list of dictionaries called "donations" using the content from the image below:![alt text](https://raw.githubusercontent.com/sandeepmj/practical_python_exercises/master/support_files/donors.png) If you want to copy and paste the content, click here to download the Excel file.More instructions in the next cell:<jupyter_code>## You may copy the contents of each cell in the XLSX file, but...
## ...type out all the code.
## print the list of dictionaries


donations = [
    {"year": 2017, "donor": "<NAME>och Charitable Foundation", "grantee": "City Center for Music and Drama", "amount": 15E6}, 
    {"year": 2013, "donor": "Bradley Impact Fund", "grantee": "Young Americans", "amount": 11E3}, 
    {"year": 2016, "donor": "Mercer Family Foundation", "grantee": "The Becket Fund", "amount": 250E3}, 
    {"year": 2012, "donor": "Charles Koch Foundation", "grantee": "The Phillips Foundation", "amount": 25E3},
    {"year": 2017, "donor": "<NAME> Foundation", "grantee": "Boys Scouts of America", "amount": 26346E2}
]
donations
for mydict in donations:
  print(mydict)
## How many items are in this list?
## Don't just manually count them.
## There will come a time when you will have thousands of items!
len(donations)
## How many key/value pairs are there in the last dictionary
len(donations[4])
## Add one more key/value pair to the first dictionary in the list
## Add: "category": "youth"
donations[0].update({"category": "youth"})
donations
## Show the 3rd item in the list (including keys and values)
donations[2]
##show the 2nd through last:
donations[1:]
## Go full circle and create a list that holds just the column headers.
## Call that list "csv_columns"
## print the list
csv_columns = [*donations[0]]
# csv_columns = list(donations[0])
csv_columns<jupyter_output><empty_output><jupyter_text>Removing items from a dictionaryWe realize the first item in the list of dictionaries is the only one with "category" key.<jupyter_code>## Remove that single key/value pair prior to the next task.
del donations[0]["category"]
donations[0]
## Create the column headers again
## Call that list "csv_columns"
## print the list
csv_columns = [*donations[0]]
# csv_columns = list(donations[0])
csv_columns<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11963007159904535, 'fraction_numerical': 0.034307875894988064, 'mean_word_length': 5.587426326129666, 'pattern_counts': {'":': 22, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '67667', 'license': 'MIT', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1039, 'n_words': 394, 'path': 'homework/homework-for-week-2-SOLUTIONS.ipynb', 'repo_name': 'jchapamalacara/fall21-students-practical-python', 'size': '3369'}