Create a Contact Book using Python
Contact Book with Python
A contact book is a database used to store entries related to a person’s contacts like a phone number, email address, etc. It is also known as the address book. In this article, I’ll walk you through how to create a contact book with Python.
Create a Contact Book using Python
Creating a contact book is a great project for someone who is at an intermediate level in Python. Somehow this follows the use of data structures and algorithms as we are going to add contacts to the book and find them using the person’s name.
So, creating a contacts book in Python will help you show and improve your coding skills a lot. When creating a contacts book with Python, you need to design an algorithm that allows the user to record and find any person’s details.
In this section, I will walk you through how to create a basic contacts book with the Python programming language to store and find contacts. With a few modifications, you can use it as a project where you can implement the same algorithm on a database like MySQL to store the contacts.
Now let’s see how to design an algorithm to create a contact book with Python. Note that you can save more information other than just contact details by customizing the code below:
code:
names = []
phone_numbers = []
num = 3
for i in range(num):
name = input("Name: ")
phone_number = input("Phone Number: ") # for convert to int => int(input("Phone Number: "))
names.append(name)
phone_numbers.append(phone_number)
print("\nName\t\t\tPhone Number\n")
for i in range(num):
print("{}\t\t\t{}".format(names[i], phone_numbers[i]))
search_term = input("\nEnter search term: ")
print("Search result:")
if search_term in names:
index = names.index(search_term)
phone_number = phone_numbers[index]
print("Name: {}, Phone Number: {}".format(search_term, phone_number))
else:
print("Name Not Found")
You wrote this post very carefully. The amount of information is stunning and also a gainful article for us. Keep sharing this kind of articles, Thank you.Learn Python Programming for Kids
ReplyDeleteI just need to say this is a well-informed article which you have shared here about hoodies. It is an engaging and gainful article for us. Continue imparting this sort of info, Thanks to you.Python online Experts
ReplyDeleteUseful coding
ReplyDeleteI might want to say this is a very much informed article as we have seen here. Your approach to composing is exceptionally great and furthermore it is a valuable article for us. Gratitude for sharing an article like this.Control statement in Python
ReplyDeleteI simply needed to say this is an exquisitely formed article as we have seen here. I got some information from your article and furthermore it is a huge article for us. Gratitude for sharing an article like this.Programming Language Help Online
ReplyDelete