Challenge

Project 1 - English Dictionary App & Library Book Management System

# English Dictionary App (Console-based)

import pickle

import os

FILE_NAME = "words.txt"

def load_dictionary():

if os.path.exists(FILE_NAME):

with open(FILE_NAME, "rb") as file:

return pickle.load(file)

return {}

def save_dictionary(dictionary):

with open(FILE_NAME, "wb") as file:

pickle.dump(dictionary, file)

def add_word(dictionary):

word = input("Enter word to add: ")

if word in dictionary:

print("Word already exists.")

else:

meaning = input("Enter its meaning: ")

dictionary[word] = meaning

save_dictionary(dictionary)

print("Word added successfully.")

def find_meaning(dictionary):

word = input("Enter word to find: ")

if word in dictionary:

print(f"Meaning of {word}: {dictionary[word]}")

else:

print("Word not found.")

def update_word(dictionary):

word = input("Enter word to update: ")

if word in dictionary:

new_meaning = input("Enter new meaning: ")

dictionary[word] = new_meaning

save_dictionary(dictionary)

print("Meaning updated successfully.")

else:

print("Word not found.")

def main_menu():

dictionary = load_dictionary()

while True:

print("\nMain Menu")

print("1. Add a new word")

print("2. Find the meaning")

print("3. Update a word")

print("4. Exit")

choice = input("Enter Choice: ")

if choice == '1':

add_word(dictionary)

elif choice == '2':

find_meaning(dictionary)

elif choice == '3':

update_word(dictionary)

elif choice == '4':

print("Exiting Dictionary App. Goodbye!")

break

else:

print("Invalid choice. Please enter a number between 1 and 4.")

if __name__ == '__main__':

main_menu()

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.