SlideShare a Scribd company logo
1 of 21
YELLOW PAGES
1
A Project Report On
Yellow pages
Submitted By
DIVYANSHU
Class : XII D
Under the Guidance of
Mrs.YASHIKA MALHOTRA
PGT (Computer Science)
Department of Computer Science
AMITY INTERNATIONAL SCHOOL
PUSHP VIHAR.
2
Department of Computer Science
AMITY INTERNATIONAL SCHOOL
PUSHP VIHAR
CERTIFICATE
This is to certify that DIVYANSHU of class XII D has
completed the project “YELLOW PAGES” during
session 2015-16 under my guidance and supervision.
(Mrs.YASHIKA MALHOTRA)
PGT (Computer Science)
3
DECLARATION
I hereby declare that the project work entitle
d
“YELLOW PAGES”, submitted to
Department of Computer Science, AMITY
INTERNATIONAL SCHOOL,PUSHP VIHAR
is prepared by me. All the
coding are result of my personal efforts.
DIVYANSHU
Class XII D
4
ACKNOWLEDGEMENT
I would like to express a deep sense of thanks & gratitude to my
project guide Mrs. Yashika Malhotra for guiding me immensely through the
course of the project. He always evinced keen interest in my work. Her
constructive advice & constant motivation have been responsible for the
successful completion of this project.
My sincere thanks goes to Mrs. Ameeta Mohan, Our principal ma’am, for his
co-ordination in extending every possible support for the completion of
this project.
I also thanks to my parents for their motivation & support. I must
thanks to my classmates for their timely help & support for compilation
of this project.
Last but not the least, I would like to thank all those who had
helped directly or indirectly towards the completion of this project.
DIVYANHSU
5
Class: XII D
6
CONTENTS
1. HEADERFILESUSED. . . . . . . . . . . . . . . . . 6
2. FILESGENERATED. . . . . . . . . . . . . . . . . . .7
3. WORKING DESCRIPTION. . . . . . . . . . . . .8
4. CODING. . . . . . . . . .. . . . . . . . . . . . . . . . .9-13
5. OUTPUT SCREENS. . . . . . . . . . . . . . . . . . .14-17
6. Glossary.. . . . . . . . . . . . . . . . . . . . . . . . . . .18
7. BIBLIOGRAPHY.. . . . . . . . . . . . . . . . . . . .19
7
HEADER FILES USED
1. Import pickle: The pickle module
implements binary protocols for
serializing and de-serializing a Python
object structure.
2. Pickle.load: Read a string from the
open file object file and interpret it as a
pickle data stream, reconstructing and
returning the original object hierarchy.
3. Pickle.dump: Return the pickled
representation of the object as a string,
instead of writing it to a file.
4. EOF Error: This macro is an integer
value that is returned by a number of
narrow stream functions to indicate an
end-of-filecondition, or some other
error situation.
8
FILES GENERATED
DATA FILES
ADDRESS_BOOK_FILE
PROGRAM FILE
YELLOW PAGES.PY
EXECUTIONFILE
YELLOW PAGES .EXE
9
WORKING DESCRIPTION
This program is designed to keep the friend
’s
record.
This program consists of six options as
follows
1. TO ADD CONTACT
2. TO BROWSE THROUGH CONTACT
3. TO DELETE THE CONTACT
4. TO MODIFY THE CONTACT
5. TO SEARCH FOR CONTACT
6. TO EXIT
10
CODING
def main():
pass
if __name__ == '__main__':
main()
#!/usr/bin/python
#filename address-book.py
import pickle
import os
class Contact:
def __init__(self,name,email,phone):
self.name=name
self.email=email
self.phone=phone
def __str__(self):
return "Name:{0}nEmail
address:{1}nPhone:{2}".format(self.name,self.email,self.phone)
def change_name(self,name):
self.name=name
def change_email(self,email):
self.email=email
def change_phone(self,phone):
self.phone=phone
def add_contact():
address_book_file=open("C:Documents and
Settingsadmin.PVSR29Desktopghaddress_book_file","w")
is_file_empty=os.path.getsize("address_book_file")==0
if not is_file_empty:
list_contacts=pickle.load(address_book_file)
else:
list_contacts=[]
11
try:
contact=get_contact_info_from_user()
address_book_file=open("address_book_file","w")
list_contacts.append(contact)
pickle.dump(list_contacts,address_book_file)
print ("Contact added")
except KeyboardInterrupt:
print ("Contact not added")
except EOFError:
print ("Contact not added")
finally:
address_book_file.close()
def get_contact_info_from_user():
try:
contact_name=raw_input("Enter contact namen") #
contact_email=raw_input("Enter contact emailn")#
contact_phone=raw_input("Enter contact phone numbern")#
contact=Contact(contact_name,contact_email,contact_phone)
return contact
except EOFError as e:
#print "You entered end of file. Contact not added"
raise e
except KeyboardInterrupt as e:
#print "Keyboard interrupt. Contact not added"
raise e
def display_contacts():
address_book_file=open("address_book_file","r")
is_file_empty=os.path.getsize("address_book_file")==0
if not is_file_empty:
list_contacts=pickle.load(address_book_file)
for each_contact in list_contacts:
print (each_contact)
else:
print ("No contacts in address book")
return
address_book_file.close()
def search_contact():
#search_name=input("Enter the namen")
address_book_file=open("address_book_file","r")
12
is_file_empty=os.path.getsize("address_book_file")==0
if not is_file_empty:
search_name=raw_input("Enter the namen")
is_contact_found=False
list_contacts=pickle.load(address_book_file)
for each_contact in list_contacts:
contact_name=each_contact.name
search_name=search_name.lower()
contact_name=contact_name.lower()
if(contact_name==search_name):
print (each_contact)
is_contact_found=True
break
if not is_contact_found:
print ("No contact found with the provided search name")
else:
print ("Address book empty. No contact to search")
address_book_file.close()
def delete_contact():
#name=input("Enter the name to be deletedn")
address_book_file=open("address_book_file","r")
is_file_empty=os.path.getsize("address_book_file")==0
if not is_file_empty:
name=raw_input("Enter the name to be deletedn")
list_contacts=pickle.load(address_book_file)
is_contact_deleted=False
for i in range(0,len(list_contacts)):
each_contact=list_contacts[i]
if each_contact.name==name:
del list_contacts[i]
is_contact_deleted=True
print ("Contact deleted")
address_book_file=open("address_book_file","w")
if(len(list_contacts)==0):
address_book_file.write("")
else:
pickle.dump(list_contacts,address_book_file)
break
if not is_contact_deleted:
print ("No contact with this name found")
13
else:
print ("Address book empty. No contact to delete")
address_book_file.close()
def modify_contact():
address_book_file=open("address_book_file","r")
is_file_empty=os.path.getsize("address_book_file")==0
if not is_file_empty:
name=raw_input("Enter the name of the contact to be modifiedn")
list_contacts=pickle.load(address_book_file)
is_contact_modified=False
for each_contact in list_contacts:
if each_contact.name==name:
do_modification(each_contact)
address_book_file=open("address_book_file","w")
pickle.dump(list_contacts,address_book_file)
is_contact_modified=True
print ("Contact modified")
break
if not is_contact_modified:
print ("No contact with this name found")
else:
print ("Address book empty. No contact to delete")
address_book_file.close()
def do_modification(contact):
try:
while True:
print ("Enter 1 to modify email and 2 to modify address and 3 to quit
without modifying")
choice=raw_input()
if(choice=="1"):
new_email=raw_input("Enter new email addressn")
contact.change_email(new_email)
break
elif(choice=="2"):
new_phone=raw_input("Enter new phone numbern")
contact.change_phone(new_phone)
break
else:
print ("Incorrect choice")
break
14
except EOFError:
print ("EOF Error occurred")
except KeyboardInterrupt:
print ("KeyboardInterrupt occurred")
print ("Enter 'a' to add a contact, 'b' to browse through contacts, 'd' to delete a contact,
'm' to modify a contact, 's' to search for contact and 'q' to quit")
while True:
choice=raw_input("Enter your choicen") #gh
if choice == 'q':
break
elif(choice=='a'):
add_contact()
elif(choice=='b'):
display_contacts()
elif(choice=='d'):
delete_contact()
elif(choice=='m'):
modify_contact()
elif(choice=='s'):
search_contact()
else:
print ("Incorrect choice. Need to enter the choice again")
15
OUTPUT
1. WELCOMESCREEN
2. ADD NEW CONTACT
16
3.TO BROWSE THROUGHCONTACT
4.SEARCH THROUGHCONTACT
17
5.TO MODIFYTHE CONTACT
18
6.TO DELTETTHE CONTACT
19
GLOSSARY
 Attribute - Values associated with an
individual object. Attributesare accessed using
the 'dot syntax': a.x means fetch the x attribute
from the 'a' object.
 Class - A templatefor creatinguser-defined
objects. Class definitionsnormallycontain
method definitionsthat operateon instances of
the class.
 Docstring - A string that appears as the
lexicallyfirst expression in a module, class
definition or function/method definition is
assigned as the __doc__attributeof the object
where it is availableto documentationtools or
the help() builtin function.
 Function - A block of code that is invoked by a
"calling"program, best used to provide an
autonomousservice or calculation.
20
BIBLIOGRAPHY
1 http://www.google.com/
2 http://en.wikipedia.org
3 Computer Science with Python by Su
mita
Arora
4 Object Oriented Programming by Rober
t
Lafore
5 www.bOtskOOL.com

More Related Content

Similar to Yellow pages

Cis 170 c ilab 7 of 7 sequential files
Cis 170 c ilab 7 of 7 sequential filesCis 170 c ilab 7 of 7 sequential files
Cis 170 c ilab 7 of 7 sequential filesCIS321
 
Bangladesh university of business and technology
Bangladesh university of business and technologyBangladesh university of business and technology
Bangladesh university of business and technologyMdmahabuburRahmanLiz
 
Text editors project
Text editors projectText editors project
Text editors projectMohit kumar
 
Devry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-filesDevry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-filesnoahjamessss
 
Devry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-filesDevry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-filescskvsmi44
 
Basic Computer Works for BBA students
Basic Computer Works for BBA studentsBasic Computer Works for BBA students
Basic Computer Works for BBA studentsAnkit Gupta
 
Intern_Report.pdf
Intern_Report.pdfIntern_Report.pdf
Intern_Report.pdftegera4050
 
Python programming workshop session 4
Python programming workshop session 4Python programming workshop session 4
Python programming workshop session 4Abdul Haseeb
 
A c program of Phonebook application
A c program of Phonebook applicationA c program of Phonebook application
A c program of Phonebook applicationsvrohith 9
 
Computer Tools for Academic Research
Computer Tools for Academic ResearchComputer Tools for Academic Research
Computer Tools for Academic ResearchMiklos Koren
 
Mca pro1 online
Mca pro1 onlineMca pro1 online
Mca pro1 onlinerameshvvv
 
Lokesh 's Ip project Pokemon information
Lokesh 's Ip project Pokemon informationLokesh 's Ip project Pokemon information
Lokesh 's Ip project Pokemon informationbholu803201
 
Bca winter 2013 2nd sem
Bca winter 2013 2nd semBca winter 2013 2nd sem
Bca winter 2013 2nd semsmumbahelp
 
Telephonedirectory (1)
Telephonedirectory (1)Telephonedirectory (1)
Telephonedirectory (1)Abhay Modi
 

Similar to Yellow pages (20)

Cis 170 c ilab 7 of 7 sequential files
Cis 170 c ilab 7 of 7 sequential filesCis 170 c ilab 7 of 7 sequential files
Cis 170 c ilab 7 of 7 sequential files
 
Bangladesh university of business and technology
Bangladesh university of business and technologyBangladesh university of business and technology
Bangladesh university of business and technology
 
Text editors project
Text editors projectText editors project
Text editors project
 
Devry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-filesDevry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-files
 
Devry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-filesDevry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-files
 
Basic Computer Works for BBA students
Basic Computer Works for BBA studentsBasic Computer Works for BBA students
Basic Computer Works for BBA students
 
Python slide
Python slidePython slide
Python slide
 
Intern_Report.pdf
Intern_Report.pdfIntern_Report.pdf
Intern_Report.pdf
 
ELAVARASAN.pdf
ELAVARASAN.pdfELAVARASAN.pdf
ELAVARASAN.pdf
 
Python programming workshop session 4
Python programming workshop session 4Python programming workshop session 4
Python programming workshop session 4
 
Python basics
Python basicsPython basics
Python basics
 
A c program of Phonebook application
A c program of Phonebook applicationA c program of Phonebook application
A c program of Phonebook application
 
Computer Scientists Retrieval - PDF Report
Computer Scientists Retrieval - PDF ReportComputer Scientists Retrieval - PDF Report
Computer Scientists Retrieval - PDF Report
 
Computer Tools for Academic Research
Computer Tools for Academic ResearchComputer Tools for Academic Research
Computer Tools for Academic Research
 
Mca pro1 online
Mca pro1 onlineMca pro1 online
Mca pro1 online
 
Lokesh 's Ip project Pokemon information
Lokesh 's Ip project Pokemon informationLokesh 's Ip project Pokemon information
Lokesh 's Ip project Pokemon information
 
Bca winter 2013 2nd sem
Bca winter 2013 2nd semBca winter 2013 2nd sem
Bca winter 2013 2nd sem
 
Telephonedirectory (1)
Telephonedirectory (1)Telephonedirectory (1)
Telephonedirectory (1)
 
Beyond MVC
Beyond MVCBeyond MVC
Beyond MVC
 
Final ds record
Final ds recordFinal ds record
Final ds record
 

Recently uploaded

Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 

Recently uploaded (20)

Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 

Yellow pages

  • 2. 1 A Project Report On Yellow pages Submitted By DIVYANSHU Class : XII D Under the Guidance of Mrs.YASHIKA MALHOTRA PGT (Computer Science) Department of Computer Science AMITY INTERNATIONAL SCHOOL PUSHP VIHAR.
  • 3. 2 Department of Computer Science AMITY INTERNATIONAL SCHOOL PUSHP VIHAR CERTIFICATE This is to certify that DIVYANSHU of class XII D has completed the project “YELLOW PAGES” during session 2015-16 under my guidance and supervision. (Mrs.YASHIKA MALHOTRA) PGT (Computer Science)
  • 4. 3 DECLARATION I hereby declare that the project work entitle d “YELLOW PAGES”, submitted to Department of Computer Science, AMITY INTERNATIONAL SCHOOL,PUSHP VIHAR is prepared by me. All the coding are result of my personal efforts. DIVYANSHU Class XII D
  • 5. 4 ACKNOWLEDGEMENT I would like to express a deep sense of thanks & gratitude to my project guide Mrs. Yashika Malhotra for guiding me immensely through the course of the project. He always evinced keen interest in my work. Her constructive advice & constant motivation have been responsible for the successful completion of this project. My sincere thanks goes to Mrs. Ameeta Mohan, Our principal ma’am, for his co-ordination in extending every possible support for the completion of this project. I also thanks to my parents for their motivation & support. I must thanks to my classmates for their timely help & support for compilation of this project. Last but not the least, I would like to thank all those who had helped directly or indirectly towards the completion of this project. DIVYANHSU
  • 7. 6 CONTENTS 1. HEADERFILESUSED. . . . . . . . . . . . . . . . . 6 2. FILESGENERATED. . . . . . . . . . . . . . . . . . .7 3. WORKING DESCRIPTION. . . . . . . . . . . . .8 4. CODING. . . . . . . . . .. . . . . . . . . . . . . . . . .9-13 5. OUTPUT SCREENS. . . . . . . . . . . . . . . . . . .14-17 6. Glossary.. . . . . . . . . . . . . . . . . . . . . . . . . . .18 7. BIBLIOGRAPHY.. . . . . . . . . . . . . . . . . . . .19
  • 8. 7 HEADER FILES USED 1. Import pickle: The pickle module implements binary protocols for serializing and de-serializing a Python object structure. 2. Pickle.load: Read a string from the open file object file and interpret it as a pickle data stream, reconstructing and returning the original object hierarchy. 3. Pickle.dump: Return the pickled representation of the object as a string, instead of writing it to a file. 4. EOF Error: This macro is an integer value that is returned by a number of narrow stream functions to indicate an end-of-filecondition, or some other error situation.
  • 9. 8 FILES GENERATED DATA FILES ADDRESS_BOOK_FILE PROGRAM FILE YELLOW PAGES.PY EXECUTIONFILE YELLOW PAGES .EXE
  • 10. 9 WORKING DESCRIPTION This program is designed to keep the friend ’s record. This program consists of six options as follows 1. TO ADD CONTACT 2. TO BROWSE THROUGH CONTACT 3. TO DELETE THE CONTACT 4. TO MODIFY THE CONTACT 5. TO SEARCH FOR CONTACT 6. TO EXIT
  • 11. 10 CODING def main(): pass if __name__ == '__main__': main() #!/usr/bin/python #filename address-book.py import pickle import os class Contact: def __init__(self,name,email,phone): self.name=name self.email=email self.phone=phone def __str__(self): return "Name:{0}nEmail address:{1}nPhone:{2}".format(self.name,self.email,self.phone) def change_name(self,name): self.name=name def change_email(self,email): self.email=email def change_phone(self,phone): self.phone=phone def add_contact(): address_book_file=open("C:Documents and Settingsadmin.PVSR29Desktopghaddress_book_file","w") is_file_empty=os.path.getsize("address_book_file")==0 if not is_file_empty: list_contacts=pickle.load(address_book_file) else: list_contacts=[]
  • 12. 11 try: contact=get_contact_info_from_user() address_book_file=open("address_book_file","w") list_contacts.append(contact) pickle.dump(list_contacts,address_book_file) print ("Contact added") except KeyboardInterrupt: print ("Contact not added") except EOFError: print ("Contact not added") finally: address_book_file.close() def get_contact_info_from_user(): try: contact_name=raw_input("Enter contact namen") # contact_email=raw_input("Enter contact emailn")# contact_phone=raw_input("Enter contact phone numbern")# contact=Contact(contact_name,contact_email,contact_phone) return contact except EOFError as e: #print "You entered end of file. Contact not added" raise e except KeyboardInterrupt as e: #print "Keyboard interrupt. Contact not added" raise e def display_contacts(): address_book_file=open("address_book_file","r") is_file_empty=os.path.getsize("address_book_file")==0 if not is_file_empty: list_contacts=pickle.load(address_book_file) for each_contact in list_contacts: print (each_contact) else: print ("No contacts in address book") return address_book_file.close() def search_contact(): #search_name=input("Enter the namen") address_book_file=open("address_book_file","r")
  • 13. 12 is_file_empty=os.path.getsize("address_book_file")==0 if not is_file_empty: search_name=raw_input("Enter the namen") is_contact_found=False list_contacts=pickle.load(address_book_file) for each_contact in list_contacts: contact_name=each_contact.name search_name=search_name.lower() contact_name=contact_name.lower() if(contact_name==search_name): print (each_contact) is_contact_found=True break if not is_contact_found: print ("No contact found with the provided search name") else: print ("Address book empty. No contact to search") address_book_file.close() def delete_contact(): #name=input("Enter the name to be deletedn") address_book_file=open("address_book_file","r") is_file_empty=os.path.getsize("address_book_file")==0 if not is_file_empty: name=raw_input("Enter the name to be deletedn") list_contacts=pickle.load(address_book_file) is_contact_deleted=False for i in range(0,len(list_contacts)): each_contact=list_contacts[i] if each_contact.name==name: del list_contacts[i] is_contact_deleted=True print ("Contact deleted") address_book_file=open("address_book_file","w") if(len(list_contacts)==0): address_book_file.write("") else: pickle.dump(list_contacts,address_book_file) break if not is_contact_deleted: print ("No contact with this name found")
  • 14. 13 else: print ("Address book empty. No contact to delete") address_book_file.close() def modify_contact(): address_book_file=open("address_book_file","r") is_file_empty=os.path.getsize("address_book_file")==0 if not is_file_empty: name=raw_input("Enter the name of the contact to be modifiedn") list_contacts=pickle.load(address_book_file) is_contact_modified=False for each_contact in list_contacts: if each_contact.name==name: do_modification(each_contact) address_book_file=open("address_book_file","w") pickle.dump(list_contacts,address_book_file) is_contact_modified=True print ("Contact modified") break if not is_contact_modified: print ("No contact with this name found") else: print ("Address book empty. No contact to delete") address_book_file.close() def do_modification(contact): try: while True: print ("Enter 1 to modify email and 2 to modify address and 3 to quit without modifying") choice=raw_input() if(choice=="1"): new_email=raw_input("Enter new email addressn") contact.change_email(new_email) break elif(choice=="2"): new_phone=raw_input("Enter new phone numbern") contact.change_phone(new_phone) break else: print ("Incorrect choice") break
  • 15. 14 except EOFError: print ("EOF Error occurred") except KeyboardInterrupt: print ("KeyboardInterrupt occurred") print ("Enter 'a' to add a contact, 'b' to browse through contacts, 'd' to delete a contact, 'm' to modify a contact, 's' to search for contact and 'q' to quit") while True: choice=raw_input("Enter your choicen") #gh if choice == 'q': break elif(choice=='a'): add_contact() elif(choice=='b'): display_contacts() elif(choice=='d'): delete_contact() elif(choice=='m'): modify_contact() elif(choice=='s'): search_contact() else: print ("Incorrect choice. Need to enter the choice again")
  • 20. 19 GLOSSARY  Attribute - Values associated with an individual object. Attributesare accessed using the 'dot syntax': a.x means fetch the x attribute from the 'a' object.  Class - A templatefor creatinguser-defined objects. Class definitionsnormallycontain method definitionsthat operateon instances of the class.  Docstring - A string that appears as the lexicallyfirst expression in a module, class definition or function/method definition is assigned as the __doc__attributeof the object where it is availableto documentationtools or the help() builtin function.  Function - A block of code that is invoked by a "calling"program, best used to provide an autonomousservice or calculation.
  • 21. 20 BIBLIOGRAPHY 1 http://www.google.com/ 2 http://en.wikipedia.org 3 Computer Science with Python by Su mita Arora 4 Object Oriented Programming by Rober t Lafore 5 www.bOtskOOL.com