Certainly! Below is a simple Dictionary App written in Python. This app allows users to:
- Look up the meaning of a word
- Add new words and their meanings
- Update the meaning of an existing word
- Delete a word from the dictionary
This is a console-based application for simplicity. If you want a GUI or web version, let me know!
# Simple Dictionary App in Python
def display_menu():
print("\n--- Dictionary App ---")
print("1. Look up a word")
print("2. Add a new word")
print("3. Update a word")
print("4. Delete a word")
print("5. Show all words")
print("6. Exit")
def lookup_word(dictionary):
word = input("Enter the word to look up: ").strip().lower()
meaning = dictionary.get(word)
if meaning:
print(f"{word.capitalize()}: {meaning}")
else:
print("Word not found in the dictionary.")
def add_word(dictionary):
word = input("Enter the new word: ").strip().lower()
if word in dictionary:
print("Word already exists. Use update option to change its meaning.")
else:
meaning = input("Enter the meaning: ").strip()
dictionary[word] = meaning
print(f"Word '{word}' added successfully.")
def update_word(dictionary):
word = input("Enter the word to update: ").strip().lower()
if word in dictionary:
meaning = input("Enter the new meaning: ").strip()
dictionary[word] = meaning
print(f"Word '{word}' updated successfully.")
else:
print("Word not found in the dictionary.")
def delete_word(dictionary):
word = input("Enter the word to delete: ").strip().lower()
if word in dictionary:
del dictionary[word]
print(f"Word '{word}' deleted successfully.")
else:
print("Word not found in the dictionary.")
def show_all_words(dictionary):
if not dictionary:
print("Dictionary is empty.")
else:
print("\n--- All Words in Dictionary ---")
for word, meaning in sorted(dictionary.items()):
print(f"{word.capitalize()}: {meaning}")
def main():
dictionary = {
"python": "A high-level programming language.",
"algorithm": "A step-by-step procedure for solving a problem."
}
while True:
display_menu()
choice = input("Enter your choice (1-6): ").strip()
if choice == '1':
lookup_word(dictionary)
elif choice == '2':
add_word(dictionary)
elif choice == '3':
update_word(dictionary)
elif choice == '4':
delete_word(dictionary)
elif choice == '5':
show_all_words(dictionary)
elif choice == '6':
print("Exiting Dictionary App. Goodbye!")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()
How to run:
- Copy the code into a file, e.g.,
dictionary_app.py.
- Run it with
python dictionary_app.py.
If you want a web-based or mobile version, or want to use a database, let me know your requirements!