The Python Contact Book Project provides an interactive console text-based application where users can store, retrieve, edit, and delete their contacts. User can store their contact's name, phone number, email, and address.
The primary data structure was a built-in Python dictionary, which was tasked with managing contact entries. This structure was chosen due to its efficiency in handling these particular operations (O(1) average complexity for add, delete, get operations).
The project consists of the following files and directories.
src
| ├── contact_book.py
| └── main.py
|
README.md
The project structure was designed to be simple and clean.
README.md: this document providing project description and documentationcontact_book.py: the Python script that defines the ContactBook class which encapsulates the core functionalities of the applicationmain.py: the main script which interacts with the user and uses ContactBook class methods to provide the desired functionality
The core logic of the application is implemented in ContactBook class:
-
The
add_contactmethod allows for new entries to be made to the 'book'. Each entry must be unique by name. -
The
update_contactmethod permits updates to contact information. -
The
view_contactsmethod lists all contacts in the address book along with their information. -
The
delete_contactmethod allows for existing contacts to be removed from the book.
The main.py file serves as an interface between the user and the ContactBook class instance. It gets user inputs, calls the necessary methods and handles the application flow.
The interface is a simple console-based menu that offers users options to add, view, edit, delete contacts or quit the program.
To run the program, navigate to the project directory and run the following command:
python src/main.py