1. Here is your homework 2. You should be able to work on this homework after topic 0-4. You can submit for multiple times but only the last submission before deadline will be graded.

    Please answer the following questions.

    1. What is garbage collection in python? Please give the definition of this terminology and an example of garbage collection by using object string d = dict(name=’Bob’,job=’dev’,age=40).

    2. Coding question. You can refer to the codes from the materials. And try/practice in the python playground or env if you set it up before answering these questions.

    2-1 List Practice. This is a series of questions on the application of simple iteration. An example of iteration in material is [row[1] for row in M if row[1]%2 == 1] from topic List_Part2.

    Now assume we have a nested string list M = [[‘g’,’o’,’o’,’d’], [‘C’, ‘U’, ‘N’, ‘Y’]], please give codes below.

    • Question 2-1-1: Please append ‘!’ for each nested list by creating a new list. (Expected result is [[‘g’, ‘o’, ‘o’, ‘d’, ‘!’], [‘C’, ‘U’, ‘N’, ‘Y’, ‘!’]] but M should keep same as original) 
      hint: do list concatenation for each list by using + [‘!’]
    • Question 2-1-2: Return a list that only has Ms nested list with ‘Y’ inside. (Expected result is [[‘C’, ‘U’, ‘N’, ‘Y’]] but M should keep same as original) 
      hint: to test whether ‘Y’ is in a list L, we can use ‘Y’ in L
    • Question 2-1-3: Please repeat each string in list M for 4 times if it is upper case. (Expected result is [[‘g’, ‘o’, ‘o’, ‘d’], [‘CCCC’, ‘UUUU’, ‘NNNN’, ‘YYYY’]])
      hint: 
       1) Assume we have list  L = [1,2,3,4] and we want item + 100 if this items value equal to number 3, we can use code [i + 100 if i == 3 else i for i in L].
       2) Assume we have a = ‘A’, we can use a.isupper() to test whether a is uppercase.
       3) we can nest list then we can nest iteration.

    2-2 Dict practice. Assume we have dict    
        amazing_grace = {
           ‘name’: {
                 ‘first_name’: ‘Grace’,
                 ‘last_name’: ‘Hopper’

            },
            ‘jobs’: [‘scientist’, ‘engineer’],
            ‘age’: 85
         }

    • Question 2-2-1: Add ‘programmer’ to the list of jobs Grace has.
    • Question 2-2-2: Get the third job Grace has that you recently added.

     2-3 List and set practice. Assume we have an engineers list and managers list and no duplicate name,
         engineers = [‘bob’, ‘sue’, ‘ann’, ‘vic’, ‘mike’, ‘tom’]
         managers = [‘tom’, ‘sue’, ‘ann’]

    • Question 2-3-1: Check whether all managers are engineers.
    • Question 2-3-2: Return engineers who are not managers in set. (Expected result is set([‘vic’, ‘mike’, ‘bob’]); order doesn’t matter)

    Rubric:

    1. Q1 – 30:

    • (10) definition.
    • (20) show by example required.

    2. Q2 – 70. 10 for each coding line.

    3. Submission after deadline will not be graded unless you reach out instructor for an extension in advance.


What Students Are Saying About Us

.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐
"Honestly, I was afraid to send my paper to you, but you proved you are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"

.......... Customer ID: 11***| Rating: ⭐⭐⭐⭐⭐
"This company is the best there is. They saved me so many times, I cannot even keep count. Now I recommend it to all my friends, and none of them have complained about it. The writers here are excellent."


"Order a custom Paper on Similar Assignment at essayfount.com! No Plagiarism! Enjoy 20% Discount!"