Table. Table.add_column("#", style="dim", width=3, justify="center") Header_style="bold blue", show_lines=True) Return f"(")Ĭonsole.print("Contact Book", "□")Ĭonsole.print("No contacts to show") Self.date_updated = date_updated if date_updated is not None else ().isoformat() Here are various Python projects which are covered in three categories: 1) Beginner, 2) Intermediate, and 3) Advanced-level Python projects ideas as given below: Beginners Level 1) Sudoku Solver Sudoku is a top-rated logic-based number-placement puzzle game. Self.date_created = date_created if date_created is not None else ().isoformat() Then add the following content in the file: import datetimeĭef _init_ (self, name, contact_number, position=None, date_created=None, date_updated=None): Inside that, create a Python file called model.py. We'll be moving forward with these two for now.Ĭreate a directory called contact_book. If you can think of more, you can add them to your model. I can think of these fields – name and contact number. Think of all the fields that contact should have. Remove (or Delete): You can delete the contacts saved in the contact book.įirst of all, we'll create a custom class or a model for our Contact.Edit (or Update): You can edit the contacts saved in the contact book.Show (or Read): You can see all your contacts saved in the contact book.Add (or Create): You can add a new contact in the contact book.Similar to a Todo application, we can perform the following operations on it: Our Contact Book application will be a terminal-based application. TinyDB: TinyDB is a document-oriented database written in pure Python with no external dependencies.Typer: Typer is a library for building CLI applications.Rich: Rich is a Python library for writing rich text (with color and style) to the terminal, and for displaying advanced content such as tables, markdown, and syntax highlighted code.To verify if the environment has been activated or not, you can see (env) in your terminal. Now, we need to activate the environment using the command: $. The above command will create a virtual environment named env. So, to create a virtual environment, you can use the below command: $ python -m venv env Python now ships with a pre-installed virtualenv library. We are going to create a virtual environment using virtualenv. Let's learn more about them and install them one by one.īut before we install them, let's create a virtual environment and activate it. We'll be using a few external libraries in this project. We'll use Typer for building the CLI app, Rich for a colorized terminal output, and TinyDB for the database. Please try again.In this Python tutorial, we'll learn how to build a terminal application (CLI app) to manage our contact book. If update_contact(contacts, name, phone, email): Next, we load the contacts from the CSV file using the load_csv function and display a menu with options to add, search, update, and delete contacts. With open("contacts.csv", "a", newline="") as file:ĭef update_contact(contacts, name, phone, email): With open("contacts.csv", newline="") as file: With open("contacts.csv", "w", newline="") as file: Here, we define functions to create a new CSV file with a header row, load the CSV file into a list of dictionaries, add a new contact to the CSV file, search for a contact by name, update an existing contact, and delete a contact. Next, we define several functions – create_csv, load_csv, add_contact, search_contact, update_contact, and delete_contact.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |