FOOD 101 _ Assignment 0
FOOD 101 _ Assignment 0
Write a Python program that demonstrates the usage of the pickle module by performing the
following operations:
1. Create a dictionary where the keys are the names of fruits, and the values are their prices
(e.g., {"apple": 100, "banana": 40}).
2. Save this dictionary to a binary file using the pickle module.
3. Read the dictionary back from the binary file and display its contents.
4. Update the price of a specific fruit by:
○ Prompting the user to enter the fruit's name and the new price.
○ Checking if the fruit exists in the dictionary.
○ If the fruit exists, update its price and save the updated dictionary back to the binary file.
○ If the fruit does not exist, inform the user.
5. Read and display the updated dictionary from the binary file.
Given a string str1 that contains words separated by spaces without any punctuation, complete
the function num_unique_words to return the number of unique words in the string.
● You are not allowed to use any external libraries; only Python built-in functions should be
used.
● Think carefully about how you can achieve this using basic Python operations/functions.