Assignments 2
Assignments 2
Python Assignments
o The function should return a dictionary where keys are unique words (case-
insensitive) from the text, and values are their respective frequencies.
o Use a dictionary where keys are contact names (strings) and values are
dictionaries containing "phone" (string) and "email" (string).
▪ delete_contact(name)
o Develop a basic inventory system. Use a dictionary where keys are item
names (strings) and values are dictionaries containing "quantity" (integer) and
"price" (float).
▪ update_quantity(name, new_quantity)
▪ calculate_total_value() (sums up the value of all items in inventory:
quantity * price)
▪ display_inventory()
▪ deposit(amount)
▪ get_balance()
▪ get_account_details()
5. Palindrome Checker:
o Write a function is_palindrome(text) that takes a string and returns True if it's
a palindrome (reads the same forwards and backward, ignoring case and
spaces), False otherwise.
o The Fibonacci sequence starts with 0 and 1, and each subsequent number is
the sum of the two preceding ones (0, 1, 1, 2, 3, 5, 8...).
o Example input: [{'name': 'Alice', 'age': 30}, {'name': 'Bob', 'age': 25}]
▪ calculate_average(numbers)
▪ find_max(numbers)
▪ find_min(numbers)
o If a key exists in both dictionaries, the value from dict2 should override the
value from dict1.
o Example: merge_dictionaries({'a': 1, 'b': 2}, {'b': 3, 'c': 4}) should return {'a': 1,
'b': 3, 'c': 4}.
12. Remove Duplicates from a List (Preserving Order):