Challenge

Project 1 - Data Cleaning and Transformation using Pivot table and Charts for the Report on requirement of Team Hiring

{
"cells": [
{
"cell_type": "markdown",
"id": "3b2ac957",
"metadata": {},
"source": [
"# This project uses the skills learnt from week 1 to week 6. The aim of this project is to create an English Dictionary app that returns definitions of English words. When the application is started, it displays a menu as follows:\n",
"\n",
"Main Menu\n",
"\n",
"Add a new word\n",
"Find the meaning\n",
"Update a word\n",
"Exit\n",
"\n",
"Enter Choice:\n",
"\n",
"If item 1 is selected, it should prompt for a word and then accept its meaning. This pair of word and its meaning should be stored in a file called ‘words.txt’. When item 2 is selected, it should prompt for a word, search that word in the file ‘words.txt’ and return the meaning if it is found. If the meaning is not found, it should display an appropriate message. Similarly, when choice 3 is entered, it should accept a word and update its meaning. In all the above three cases, the prompt should return to the main menu. The words and their meanings should be stored as a dictionary in words.txt, using the concept of serialization. If choice 4 is selected, a graceful exit should be performed.\n",
" \n",
"If you want to be recognized as a professional programmer, you have to practice more and develop applications in Python which you can include in your online portfolio. To achieve this, one such comprehensive project (with two small sub-projects inside it) is added which have to be completed by every student.\n",
"\n",
"1A: English Dictionary App\n",
"\n",
"This project uses the skills learnt from week 1 to week 6. The aim of this project is to create an English Dictionary app that returns definitions of English words.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "502bad05",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Mainmenu \n",
"\n",
" 1.Add a word \n",
" 2.Find the meaning \n",
" 3.Update a word \n",
" 4.Exit \n",
"\n",
"Please select from the given main menu(1,2,3,4):4\n",
"Are you sure you want to exit?(yes/no):yes\n",
"Thank you have a nice day!!\n",
"##################################################\n"
]
}
],
"source": [
"import json\n",
"print('Mainmenu \\n\\n 1.Add a word \\n 2.Find the meaning \\n 3.Update a word \\n 4.Exit \\n')\n",
"while True:\n",
" try:\n",
" action=int(input('Please select from the given main menu(1,2,3,4):'))\n",
" except ValueError :\n",
" print('!!!!Please enter interger values only!!!')\n",
" print('#'*50)\n",
" else:\n",
" if action==4:\n",
" e=input('Are you sure you want to exit?(yes/no):')\n",
" if e=='Yes' or e=='yes':\n",
" print('Thank you have a nice day!!')\n",
" print('#'*50)\n",
" break\n",
" else:\n",
" continue\n",
" elif action==1:\n",
" word=input('Enter a new word:')\n",
" meaning=input('Enter meaning of the word you entered:')\n",
" add={word:meaning}\n",
" with open('words.txt','a')as f:\n",
" f.write(json.dumps(add))\n",
" f.write('\\n')\n",
" print('Word added sucessfully')\n",
" print('#'*50)\n",
" elif action==2:\n",
" find=input('Enter a word to find its meaning: ')\n",
" with open ('words.txt','r')as f:\n",
" data=f.read()\n",
" if find in data:\n",
" print(f'Meaning of the word you entered is : {meaning}')\n",
" print('#'*50)\n",
" continue\n",
" else:\n",
" print('Word not found')\n",
" print('#'*50)\n",
" elif action==3:\n",
" oldword=input('Enter a word to be updated:')\n",
" with open ('words.txt','r')as f:\n",
" data=f.read()\n",
" if oldword in data:\n",
" newword=input('Enter new a word:')\n",
" data = data.replace(oldword,newword)\n",
" with open(\"words.txt\", \"w\") as file:\n",
" file.write(data)\n",
" print(f'{oldword} has been updated to {newword}')\n",
" print('#'*50)\n",
" continue\n",
" else:\n",
" print('Word not found')\n",
" print('#'*50)\n",
" else:\n",
" print('!!!Please choose the correct option from the Main menu!!!')\n",
" print('#'*50)"
]
},
{
"cell_type": "markdown",
"id": "7cb1124f",
"metadata": {},
"source": [
"1B: Library Book Management System\n",
"\n",
"In this project, a Library Book Management System will be implemented with the front end GUI developed using Tkinter and the backend database implemented in SQLite. It is a single window tkinter GUI application which will implement CRUD( create, read, update, delete) operations on a ‘books’ database, in SQLite. The window will contain text widgets to accept / display book title, author, year of publication, ISBN (optional) and a large text area/ list box to display the records which match the search criteria."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "5a5d0dcc",
"metadata": {},
"outputs": [],
"source": [
"import sqlite3 as sql \n",
"import tkinter as tk\n",
"import tkinter.ttk as ttk\n",
"import tkinter.messagebox as mb\n",
"import tkinter.simpledialog as sd\n",
"from tkinter import *\n",
"\n",
"\n",
"root=Tk()\n",
"root.title('.....Library Management Application.....')\n",
"\n",
"\n",
"def Database():\n",
" global conn,cursor\n",
" conn=sql.connect('simple.db')\n",
" cursor=conn.cursor()\n",
" cursor.execute('CREATE TABLE IF NOT EXISTS Booklibrary(Bookname TEXT,Author TEXT,Year TEXT, ISBN TEXT)')\n",
"\n",
"def create():\n",
" if BOOKNAME.get()==\"\" or AUTHOR.get()==\"\" or YEAR.get() ==\"\" or ISBN.get()==\"\":\n",
" txt_result.config(text='Please Enter all the fields',fd='red')\n",
" else:\n",
" Database()\n",
" cursor.execute('INSERT INTO Booklibrary(Bookname,Author,Year,ISBN)VALUES(?,?,?,?)',(str(BOOKNAME.get()),str(AUTHOR.get()),str(YEAR.get()),str(ISBN.get())))\n",
" conn.commit()\n",
" BOOKNAME.set(\"\")\n",
" AUTHOR.set(\"\")\n",
" YEAR.set(\"\") \n",
" #ISBN.set(\"\")\n",
" cursor.close()\n",
" conn.close()\n",
" txt_result.config(text='Record Inserted !',fg='green')\n",
"def Read():\n",
" tree.delete(*tree.get_children())\n",
" Database()\n",
" cursor.execute('SELECT * FROM Booklibrary ORDER BY Author ASC ')\n",
" fetch=cursor.fetchall()\n",
" for data in fetch:\n",
" tree.insert('','end',values=(data[0],data[1],data[2],data[3]))\n",
" cursor.close()\n",
" txt_result.config(text='Successfully fetched data !',fg='black')\n",
"def Exit():\n",
" result=mb.askquestion('Do you want to Exit ?(y/n)',icon='warning')\n",
" if result == 'yes':\n",
" root.destroy()\n",
" exit()\n",
"\n",
"\n",
"#variables..\n",
"BOOKNAME=StringVar()\n",
"AUTHOR=StringVar()\n",
"YEAR=StringVar() \n",
"ISBN=StringVar()\n",
"\n",
"\n",
"\n",
" #FRAMES\n",
"Top=Frame(root,width=900,height=50,bd=8,relief='raise')\n",
"Top.pack(side=TOP)\n",
"Left=Frame(root,width=300,height=500,bd=8,relief='raise')\n",
"Left.pack(side=LEFT)\n",
"Right=Frame(root,width=600,height=500,bd=8,relief='raise')\n",
"Right.pack(side=RIGHT)\n",
"\n",
"\n",
"Forms=Frame(Left,width=400,height=1000)\n",
"Forms.pack(side=\"top\")\n",
"\n",
"#buttons\n",
"Buttons=Frame(Left,width=300,height=100,bd=8,relief='raise')\n",
"Buttons.pack(side=\"bottom\")\n",
"\n",
"#Labels\n",
"txt_title=Label(Top,width=900,font=('arial',24),text='.....Library Management Application.....')\n",
"txt_title.pack()\n",
"txt_Bookname=Label(Forms,text='Bookname',font=('arial',16),bd=15)\n",
"txt_Bookname.grid(row=0,stick='e')\n",
"txt_Author=Label(Forms,text='Author',font=('arial',16),bd=15)\n",
"txt_Author.grid(row=1,stick='e')\n",
"txt_Year=Label(Forms,text='Year',font=('arial',16),bd=15)\n",
"txt_Year.grid(row=2,stick='e')\n",
"txt_ISBN=Label(Forms,text='ISBN',font=('arial',16),bd=15)\n",
"txt_ISBN.grid(row=3,stick='e')\n",
"txt_result=Label(Buttons)\n",
"txt_result.pack(side=TOP)\n",
"\n",
"#Entry widgets\n",
"Bookname=Entry(Forms,textvariable=BOOKNAME,width=30)\n",
"Bookname.grid(row=0,column=1)\n",
"Author=Entry(Forms,textvariable=AUTHOR,width=30)\n",
"Author.grid(row=1,column=1)\n",
"Year=Entry(Forms,textvariable=YEAR,width=30)\n",
"Year.grid(row=2,column=1)\n",
"ISBN=Entry(Forms,textvariable=ISBN,width=30)\n",
"ISBN.grid(row=3,column=1)\n",
"\n",
"#Button widgets\n",
"btn_display=Button(Buttons,width=10,text=\"Display\")\n",
"btn_display.pack(side=\"left\")\n",
"btn_search=Button(Buttons,width=10,text=\"Search\")\n",
"btn_search.pack(side=\"left\")\n",
"btn_add=Button(Buttons,width=10,text=\"Add\",command=create)\n",
"btn_add.pack(side=\"left\")\n",
"btn_issue=Button(Buttons,width=10,text=\"Issue\",command=Read)\n",
"btn_issue.pack(side=\"left\") \n",
"btn_delete=Button(Buttons,width=10,text=\"Delete\")\n",
"btn_delete.pack(side=\"left\") \n",
"btn_exit=Button(Buttons,width=10,text=\"Exit\",command=Exit)\n",
"btn_exit.pack(side=\"left\") \n",
"\n",
"\n",
"#list widgets\n",
"scrollbary=Scrollbar(Right,orient=VERTICAL)\n",
"scrollbarx=Scrollbar(Left,orient=HORIZONTAL)\n",
"\n",
"tree=ttk.Treeview(Right,columns=('Book','Author','Year','Isbn'))\n",
"\n",
"scrollbary.config(command=tree.yview)\n",
"scrollbary.pack(side=\"right\",fill=Y)\n",
"scrollbarx.config(command=tree.xview)\n",
"scrollbarx.pack(side=\"bottom\",fill=X)\n",
"tree.heading('Book',text='Book',anchor=W)\n",
"tree.heading('Author',text='Author',anchor=W)\n",
"tree.heading('Year',text='Year',anchor=W)\n",
"tree.heading('Isbn',text='ISBN',anchor=W)\n",
"tree.column('#0',stretch=NO,minwidth=0,width=0)\n",
"tree.column('#1',stretch=NO,minwidth=0,width=80)\n",
"tree.column('#2',stretch=NO,minwidth=0,width=120)\n",
"tree.column('#3',stretch=NO,minwidth=0,width=160)\n",
"tree.pack()\n",
"#instaaliztion\n",
"root.mainloop()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2bb31724",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "f4bc985b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

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.