Developing a Phonebook Using Python
Developing a Phonebook Using Python
PHONEBOOK
USING PYTHON
Submitted by :
Name : S.Satya Sai
Section : N
Roll no : 16
JNTU no : 21341A03C3
Branch : Mechanical
DEVELOPING A PHONEBOOK USING PYTHON
ABSTRACT :
This augument experiment to implement a smartphone directory that collects contact data
from the user until the user prompts the program to. Contact data refers to the contact’s
name, phone number, date-of-birth, a category that contact belongs to (Friends, Family,
Work, Other), e-mail address. The user may enter as much data as he can in the mentioned
data labels. If some labels remain void of data, store it as None. A name & the number is
mandatory to create contact. Implement the following operations on the directory: Insert,
Delete, Search, Display.
OPERATIONS :
1) Adding contacts to phonebook
2) Searching contacts in phonebook
3) Display all the contacts in the phonebook
4) Editing the contacts
5) Deleting contacts in the phonebook
CONCEPTS USED :
1) Dictionary
2) While loop
3) For loop
4) Conditional statement
5) Calling a function
6) Membership operators
PROGRAM CODE :
contact = {}
def display_contact():
print("name\t\tcontact number")
for key in contact:
print("{}\t\t{}".format(key,contact.get(key)))
while True:
choice = int(input("\n 1. ADD NEW CONTACT \n 2. SEARCH CONTACT \n 3.
DISPLAY CONTACT \n 4. EDIT CONTACT \n 5. DELETE CONTACT \n 6. EXIT \n\n
ENTER YOUR CHOICE:"))
if choice == 1:
name = input("\nEnter the contact name:")
phone = input("Enter the phone number:")
contact[name] = phone
elif choice == 2:
search_name = input("Enter the contact name:")
if search_name in contact:
print(search_name,"contact number is ",contact[search_name])
else:
print("Name is not found")
elif choice == 3:
if not contact:
print("Empty contact book")
else:
display_contact()
elif choice == 4:
edit_contact = input("Enter the contact name to edit:")
if edit_contact in contact:
phone = input("Enter phone number:")
contact[edit_contact]=phone
print("Contact updated")
display_contact()
else:
print("Name is not found")
elif choice == 5:
del_contact = input("Enter the contact name to delete:")
if del_contact in contact:
confirm = input("Do you want to delete this contact yes/no?")
if confirm =='yes' or confirm == 'YES':
contact.pop(del_contact)
display_contact()
else:
print("Name is not found")
else:
break
OUTPUT 1 :
OUTPUT 2 :