Challenge

Project 1 - English Dictionary App & Library Book Management System

# English Dictionary App

import json
import pickle
import os

'''def savedictionary(x):
try:
with open('words.txt','wb')as dictionary:
pickle.dump(x,dictionary)

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')
def addnewword():
x = input(enter)
dictionary=savedictionary.get'''


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')

Enter the Choice:1
Enter a word : apple
Enter its meaning : fruit
Enter the Choice:2
Enter the word to find: carrot
Sorry the word is not found
Enter the Choice:3
Enter the word:carrot
Enter the updated meaning: vegetable
Enter the Choice:4
Thank you for choosing Dictionary app

LBMS

# Libraries
from tkinter import *
import sqlite3
import tkinter.ttk as ttk
import tkinter.messagebox as tkMessageBox

root = Tk()
root.title('Library Management System')

''

def Database():
global conn, cursor
conn = sqlite3.connect('simple.db')
cursor = conn.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS books (booktitle TEXT, author TEXT, yearofpublication INTEGER,isbn INTEGER)")
def create():
if BOOKTITLE.get()=="" or AUTHOR.get()=="" or YEAROFPUBLICATION.get()=="" or ISBN.get()=="":
txt_result.config(text="please enter all the fields",fd="red")
else:
Database()
cursor.execute("INSERT INTO books(booktitle,author,yearofpublication) VALUES(?,?,?,?)",str(booktiltle.get()),str(author.get()),int(yearofpublication.get(),int(isbn)))
conn.commit()
BOOKTITLE.set("")
AUTHOR.set("")
YEAROFPUBLICATION.set("")
cursor.close()
conn.close()
txt_result.config(text="Record Inserted !",fg="green")
def term_db(connection):
connection.close()

def Read():

cursor.execute("SELECT * FROM books ORDER BY booktitle ASC")
fetch = cursor.fetchall()
return fetch
def addtable(cursor,Booktitle,Author,Year,ISBN):
for data in fetch:
insert('','end',values=(data[1],data[2],data[3],data[4]))
cursor.close()
txt_result.config(text="successfully fetched data !",fg="black")
def update(cursor,Booktitle,Author,Year,ISBN):
conn = sqlite3.connect('simple.db')
cur = conn.cursor()
cur.execute(" UPDATE books ")
conn.commit()
conn.close()
def delete(cursor,Booktitle,Author,Year,ISBN):
conn = sqlite3.connect('simple.db')
cur = conn.cursor()
cur.execute("DELETE FROM books")
conn.commit()
conn.close()
def searchfromtable(cursor,Booktitle,Author,Year,ISBN):
try:
cursor.execute("SELECT * FROM books WHERE title=?",(title,))
fetch_delete=fetchall()
cursor.execute("SELECT * FROM books WHERE author=?",(author,))
fetch_delete=fetchall()
cursor.execute("SELECT * FROM books WHERE title=?",(year,))
fetch_delete=fetchall()
cursor.execute("SELECT * FROM books WHERE title=?",(ISBN,))
fetch_delete=fetchall()

def Exit():
result = tkMessageBox.askquestion('Do you want to exit ? (y/n)',icon='warning')
if result == 'yes':
root.destroy()
exit()

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

def gui():
root = Tk()
root.title("Library book management system")

l1=Label(root,text='Book Title',padx=10)

l2=Label(root,text='Author',padx=10)

l3=Label(root,text='Year of Publication',padx=10)

l4=Label(root,text='ISBN',padx=10)

Booktitle = StringVar()
Author = StringVar()
Yearofpublication=StringVar()
ISBN=StringVar()
t1 = Entry(root,textvariable=Booktitle)
t2 = Entry(root,textvariable=Author)
t3 = Entry(root,textvariable=Yearofpublication)
t4 = Entry(root,textvariable=ISBN)
b1= Button(text='Display',command='update')
b2=Button(text='Create',command='create')
b3=Button(text='Read',command='read')
b4=Button(text='Delete',command='delete')
l1.grid(row=0,column=0)
l2.grid(row=0,column=2)
l3.grid(row=0,column=4)
l4.grid(row=0,column=6)
t1.grid(row=0,column=1)
t2.grid(row=0,column=3)
t3.grid(row=0,column=5)
t4.grid(row=0,column=7)
b1.grid(row=2,column=0)
b2.grid(row=2,column=1)
b3.grid(row=2,column=2)
b4.grid(row=2,column=3)
root.mainloop()
gui()

if __name__ == '__main__':
root.tk.mainloop()



 
​
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.