Andrew K.

asked • 05/15/21

Dictonary_Assignment

1. Give three examples of real-world objects that behave like a dictionary.

2. Assume that the variable data refers to the dictionary {“b”:20, “a”:35}.

  Write the values of the following expressions(ie results)

  a. data[“a”]

  b. data.get(“c”, None)

  c. len(data)

  d. data.keys()

  e. data.values()

  f. data.pop(“b”)

  g. data # After the pop above

3. Assume that the variable data refers to the dictionary {“b”:20, “a”:35}.

  Write the expressions that perform the following tasks (ie python code):

  a. Replace the value at the key “b” in data with that value’s negation.

  b. Add the key/value pair “c”:40 to data.

  c. Remove the value at key “b” in data, safely.

  d. Print the keys in data in alphabetical order.

1 Expert Answer

By:

Patrick B. answered • 05/16/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.