All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
English Dictionary App import pickle # Initialize an empty dictionarydictionary = {} # Open the file in write mode and serialize the dictionarywith open("words.txt", "wb") as file: pickle.dump(dictionary, file) print("words.txt file created successfully!") ---------------------------------------------- import pickle def…
ANANYA RAO
updated on 23 May 2023
English Dictionary App
import pickle
# Initialize an empty dictionary
dictionary = {}
# Open the file in write mode and serialize the dictionary
with open("words.txt", "wb") as file:
pickle.dump(dictionary, file)
print("words.txt file created successfully!")
----------------------------------------------
import pickle
def add_word():
word = input("Enter the word: ")
meaning = input("Enter the meaning: ")
with open("words.txt", "rb") as file:
dictionary = pickle.load(file)
dictionary[word] = meaning
with open("words.txt", "wb") as file:
pickle.dump(dictionary, file)
print("Word and meaning added successfully!")
def find_meaning():
word = input("Enter the word: ")
with open("words.txt", "rb") as file:
dictionary = pickle.load(file)
if word in dictionary:
print(f"Meaning: {dictionary[word]}")
else:
print("Meaning not found.")
def update_word():
word = input("Enter the word to update: ")
with open("words.txt", "rb") as file:
dictionary = pickle.load(file)
if word in dictionary:
new_meaning = input("Enter the new meaning: ")
dictionary[word] = new_meaning
with open("words.txt", "wb") as file:
pickle.dump(dictionary, file)
print("Word meaning updated successfully!")
else:
print("Word not found.")
def main_menu():
while True:
print("\nMain Menu\n")
print("1. Add a new word")
print("2. Find the meaning")
print("3. Update a word")
print("4. Exit\n")
choice = input("Enter Choice: ")
if choice == "1":
add_word()
elif choice == "2":
find_meaning()
elif choice == "3":
update_word()
elif choice == "4":
print("Exiting...")
break
else:
print("Invalid choice. Please try again.")
main_menu()
Library Book Management System
from tkinter import *
import sqlite3
import tkinter.ttk as ttk
import tkinter.messagebox as messagebox
root = Tk()
root.title('A Library Application!')
def Database():
global conn, cursor
conn = sqlite3.connect('books.db')
cursor = conn.cursor()
cursor.execute(
"""CREATE TABLE IF NOT EXISTS books(id INTEGER PRIMARY KEY AUTOINCREMENT,title TEXT,author TEXT,year INTEGER,isbn INTEGER)""")
def Add():
if BOOKTITLE.get() == "" or AUTHOR.get() == "" or YEAR.get() == "" or ISBN.get() == "":
txt_result.config(text="Please enter all the fields", fg='red')
else:
Database()
cursor.execute("INSERT INTO books (title, author, year, isbn) VALUES (?, ?, ?, ?)",
(BOOKTITLE.get(), AUTHOR.get(), YEAR.get(), ISBN.get()))
conn.commit()
BOOKTITLE.set("")
AUTHOR.set("")
YEAR.set("")
ISBN.set("")
cursor.close()
conn.close()
txt_result.config(text="Record Inserted", fg='green')
def Display():
tree.delete(*tree.get_children())
Database()
cursor.execute('SELECT * FROM books ORDER BY title ASC')
fetch = cursor.fetchall()
for data in fetch:
tree.insert('', 'end', values=(data[1], data[2], data[3], data[4]))
cursor.close()
txt_result.config(text="Successfully fetched data", fg='black')
def Issue():
selected_item = tree.selection()
if not selected_item:
txt_result.config(text="Please select a book", fg='red')
else:
book_info = tree.item(selected_item)['values']
book_title = book_info[0]
messagebox.showinfo("Issue Book", f"Book '{book_title}' issued successfully")
def Delete():
selected_item = tree.selection()
if not selected_item:
txt_result.config(text="Please select a book", fg='red')
else:
result = messagebox.askquestion('Delete Book', 'Are you sure you want to delete this book?', icon='warning')
if result == 'yes':
book_info = tree.item(selected_item)['values']
book_title = book_info[0]
Database()
cursor.execute("DELETE FROM books WHERE title=?", (book_title,))
conn.commit()
cursor.close()
conn.close()
tree.delete(selected_item)
txt_result.config(text="Book deleted successfully", fg='green')
def Exit():
result = messagebox.askquestion('Do you want to exit? (y/n)', icon='warning')
if result == 'yes':
root.destroy()
exit()
BOOKTITLE = StringVar()
AUTHOR = StringVar()
YEAR = StringVar()
ISBN = StringVar()
Top = Frame(root, width=900, height=50, bd=8, relief='raise')
Top.pack(side=TOP)
Left = Frame(root, width=300, height=500, bd=8, bg='red', relief='raise')
Left.pack(side=LEFT)
Right = Frame(root, width=600, height=500, bd=8, bg='yellow', relief='raise')
Right.pack(side=RIGHT)
Forms = Frame(Left, width=300, height=450)
Forms.pack(side=TOP)
Buttons = Frame(Left, width=300, height=100, bd=8, relief='raise')
Buttons.pack(side=BOTTOM)
# Create labels for book details
txt_title = Label(Top, width=900, font=('arial', 24), text="...Library Management Application...")
txt_title.pack()
txt_title = Label(Forms, text="Booktitle:", font=('arial', 16), bd=15)
txt_title.grid(row=0, sticky="e")
txt_author = Label(Forms, text="Author:", font=('arial', 16), bd=15)
txt_author.grid(row=1, sticky="e")
txt_year = Label(Forms, text="Year:", font=('arial', 16), bd=15)
txt_year.grid(row=2, sticky="e")
txt_isbn = Label(Forms, text="ISBN:", font=('arial', 16), bd=15)
txt_isbn.grid(row=3, sticky="e")
txt_result = Label(Buttons)
txt_result.pack(side=TOP)
# entry fields
booktitle = Entry(Forms, textvariable=BOOKTITLE, width=30)
booktitle.grid(row=0, column=1)
author = Entry(Forms, textvariable=AUTHOR, width=30)
author.grid(row=1, column=1)
year = Entry(Forms, textvariable=YEAR, width=30)
year.grid(row=2, column=1)
isbn = Entry(Forms, textvariable=ISBN, width=30)
isbn.grid(row=3, column=1)
# buttons
btn_add = Button(Buttons, width=10, text="Add", command=Add)
btn_add.pack(side=LEFT)
btn_display = Button(Buttons, width=10, text="Display", command=Display)
btn_display.pack(side=LEFT)
btn_search = Button(Buttons, width=10, text="Search")
btn_search.pack(side=LEFT)
btn_delete = Button(Buttons, width=10, text="Delete", command=Delete)
btn_delete.pack(side=LEFT)
btn_issue = Button(Buttons, width=10, text="Issue", command=Issue)
btn_issue.pack(side=LEFT)
btn_exit = Button(Buttons, width=10, text="Exit", command=Exit)
btn_exit.pack(side=LEFT)
# list widget
scrollbar_y = Scrollbar(Right, orient=VERTICAL)
scrollbar_x = Scrollbar(Right, orient=HORIZONTAL)
tree = ttk.Treeview(Right, columns=("title", "author", "year", "isbn"), yscrollcommand=scrollbar_y.set,
xscrollcommand=scrollbar_x.set)
scrollbar_y.config(command=tree.yview)
scrollbar_y.pack(side=RIGHT, fill=Y)
scrollbar_x.config(command=tree.xview)
scrollbar_x.pack(side=BOTTOM, fill=X)
tree.heading('title', text="Book Title", anchor=W)
tree.heading('author', text="Author", anchor=W)
tree.heading('year', text="Year", anchor=W)
tree.heading('isbn', text="ISBN", anchor=W)
tree.column('#0', stretch=NO, minwidth=0, width=80)
tree.column('#1', stretch=NO, minwidth=0, width=80)
tree.column('#2', stretch=NO, minwidth=0, width=80)
tree.column('#3', stretch=NO, minwidth=0, width=80)
tree.pack()
# Initialization
if __name__ == '__main__':
Database()
root.mainloop()
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Project 2 - EDA on Vehicle Insurance Customer Data
Project 2 - EDA on Vehicle Insurance Customer Data The "Project 2 - EDA on Vehicle Insurance Customer Data" is an exploratory data analysis project focused on analyzing and gaining insights from a dataset containing customer data in the vehicle insurance domain. The objective of this project is to explore and understand…
25 May 2023 05:26 PM IST
Project 1 - English Dictionary App & Library Book Management System
English Dictionary App import pickle # Initialize an empty dictionarydictionary = {} # Open the file in write mode and serialize the dictionarywith open("words.txt", "wb") as file: pickle.dump(dictionary, file) print("words.txt file created successfully!") ---------------------------------------------- import pickle def…
23 May 2023 01:45 PM IST
Project 2 - Gender Bias in Science and Technical field
Title: Literacy Rate in Tamilnadu
23 Mar 2023 07:38 AM IST
Project 1 - Analyzing the Education trends in Tamilnadu
Analyzing the Education trends in Tamilnadu The dashboard : -A pie graph of women inBiological ScientistsChemists & Materials ScientistsComputer & Mathematical OccupationsEngineers & Architects -The trend of percent women graduating in Computer science and Engineering from 2000-2015Should be in text after the…
21 Mar 2023 08:28 AM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.