Address book management system 2.0 Mainly to train students to python Function calls and python Application and exit of dead cycle .
python Student address book management system of basic project practice 1.0
python Student address book management system of basic project practice 3.0
Function module analysis
1. home page ( Menu functions )
2. Add users
3. Delete user
4. Modify the user
5. Count the number of contacts in the address book
6. Get all user communication information
7. Exit the system
The code is as follows :
def main():
while True:
menu()
number = int(input(" Please enter the steps of the operation to be implemented :"))
if number==1:
insert() # Add users
if number==2:
delete() # Delete user
if number==3:
modify() # Modify the user
if number==4:
count() # Count the number of contacts in the address book
if number==5:
disply() # Get all user communication information
if number==0:
break
if (number>5 or number<0):
print(" My guest, the input option is wrong , Please re-enter ")
students=[]
def menu():
Menu = """
============================ Student address book management system -2.0=============================
1. Add users
2. Delete user
3. Modify the user
4. Count the number of contacts in the address book
5. Get all user communication information
0. Exit the system
============================================================================
"""
print(Menu)
def insert():
while True:
student={}
student["name"]=input(" The guest officer , Please enter the name of the user to be added :")
student["age"] = input(" The guest officer , Please enter the age of the user to be added :")
student["phone"]=input(" The guest officer , Please enter the phone number of the user to be added :")
student["address"] = input(" The guest officer , Please enter the address of the user to be added :")
students.append(student)
break
def delete():
while True:
name = input(" The guest officer , Please enter the name of the user to be deleted :")
for i in students :
if i["name"]==name:
students.remove(i)
print(" The guest officer , Delete user succeeded !")
print(students)
break
def modify():
while True:
name = input(" The guest officer , Please enter the name of the user to be modified :")
for i in students:
if i["name"]== name:
i["name"]=input(" The guest officer , Please enter the name of the modified user :")
i["age"]=input(" The guest officer , Please enter the age of the modified user :")
i["phone"] = input(" The guest officer , Please enter the phone number of the modified user :")
i["address"] = input(" The guest officer , Please enter the address of the modified user :")
break
def count():
n=len(students)
print(" The address book has ",n," Contacts ")
def disply():
print('='*50)
for student1 in students:
for key,value in student1.items():
print(key,":",value)
print('='*50)
main()
figure :