Programming Exercises

  1. Dictionary of Synonyms

Write a program that creates a dictionary where the keys are words and the values are lists of synonyms. Allow the user to input a word and display its synonyms from the dictionary.

 

  1. Country Quiz

Write a program that creates a dictionary with countries as keys and their capitals as values. Randomly quiz the user on country capitals, keeping track of correct and incorrect responses.

 

  1. Phonebook Application

Write a program that allows users to add, remove, and look up contacts in a phonebook. Use a dictionary where the keys are contact names and the values are phone numbers.

 

  1. Student Grades

Write a program that creates a dictionary with student names as keys and their grades as values. Allow the user to input student names and display their grades, or add new students and grades.

 

  1. Letter Frequency Counter

Write a program that reads a text file and counts the frequency of each letter (ignoring case). Use a dictionary where the keys are letters and the values are their frequencies.

 

  1. Inventory System

Write a program that manages an inventory of products using a dictionary. The keys are product names and the values are the quantities in stock. Allow the user to add, remove, and update product quantities.

 

  1. Anagram Finder

Write a program that reads a list of words from a file and creates a dictionary where the keys are sorted strings of letters and the values are lists of words that are anagrams of those letters.

 

  1. Character Replacement Encryption

Write a program that uses a dictionary to replace each character in a string with a corresponding character. Read the input string from a file and write the encrypted string to another file.

 

  1. Common Words in Texts

Write a program that reads two text files and uses sets to find and display the common words between the two files.

 

  1. Set Operations on Names

Write a program that reads two lists of names from separate files and stores them in sets. Perform set operations (union, intersection, difference) on these sets and display the results.