Challenge

Project 1 - English Dictionary App & Library Book Management System

A)import json

print('Welcome to the Dictionary App')
print('Please select your choice')
print('1. Add a word')
print('2. Find the meaning')
print('3. Update the word')
print('4. Exit')


f = open('words.txt','w')
coll_words = {}
json.dump(coll_words,f)
f.close()

while True:
n = int(input('Enter the Choice:'))
if n == 1:
import json
f = open('words.txt','w')
word = input('Enter a word : ')
meaning = input('Enter its meaning : ')
coll_words[word] = meaning
json.dump(coll_words,f)
f.close()

elif n == 2:
import json
f = open('words.txt','r+')
dic = json.load(f)
find = input('Enter the word to find: ')
if find in coll_words:
print('The meaning is',coll_words.get(find))
else:
print('Sorry the word is not found')
json.dump(coll_words,f)
f.close()
elif n == 3:
import json
f = open('words.txt','w')
word1 = input('Enter the word:')
update_meaning = input('Enter the updated meaning: ')
coll_words[word1] = update_meaning
json.dump(coll_words,f)
f.close()
elif n == 4:
print('Thank you for choosing Dictionary app')
break
else:
print('Please enter the mentioned choice')
print('1. Add a word')
print('2. Find the meaning')
print('3. Update the word')
print('4. Exit')

B)


from tkinter import *
from tkinter import ttk
from tkinter import messagebox

def gui():
# 1. root
root = Tk()
root.title("LBMS | Library Book Management System")

# 2. widgets
title = StringVar()
author = StringVar()
year = StringVar()
isbn = StringVar()

title_label = Label(root, text="title:", padx=10)
author_label = Label(root, text="author:", padx=10)
year_label = Label(root, text="year:", padx=10)
isbn_label = Label(root, text="isbn:", padx=10)

title_entry = Entry(root, textvariable=title)
author_entry = Entry(root, textvariable=author)
year_entry = Entry(root, textvariable=year)
isbn_entry = Entry(root, textvariable=isbn)


scrollbar = Scrollbar(root, orient="vertical")
listArea = Listbox(root, bg='grey', width=100, yscrollcommand=scrollbar.set)

list_all_btn = Button(root, text="List All", command=lambda:list_all_books(listArea))
search_btn = Button(root, text="Search", command=lambda:search_book(listArea, title, author, year, isbn))
add_btn = Button(root, text="Add", command=lambda:add_book(title, author, year, isbn))
issue_btn = Button(root, text="Issue", command=lambda:issue_book(title, author, year, isbn))
del_btn = Button(root, text="delete", command=lambda:delete_book(title, author, year, isbn))
exit_btn = Button(root, text="Exit", command=root.destroy)

scrollbar.config(command=listArea.yview)

title_label.grid(row=0, column=0)
author_label.grid(row=0, column=2)
year_label.grid(row=0, column=4)
isbn_label.grid(row=0, column=6)


title_entry.grid(row=0, column=1)
author_entry.grid(row=0, column=3)
year_entry.grid(row=0, column=5)
isbn_entry.grid(row=0, column=7)

listArea.grid(row=1, column=0, columnspan=8, sticky="nsew")
scrollbar.grid(row=1, column=9, sticky="ns")

list_all_btn.grid(row=2, column=0)
search_btn.grid(row=2, column=1)
add_btn.grid(row=2, column=2)
issue_btn.grid(row=2, column=3)
del_btn.grid(row=2, column=4)
exit_btn.grid(row=2, column=7)

print("GUI loop INITIATING")

root.mainloop()
print("GUI loop TERMINATED")

gui()

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.