0% found this document useful (0 votes)
9 views

CSD110 - Design Specifications Doc - Sample 1

The document outlines the design specifications for a Python script that manages a personal phone directory, allowing users to add, search, update, and delete contacts. It includes user interaction details, programming methodology, and the structure of the code, which utilizes lists and a dictionary to store contact information. The script is intended for consumers looking to maintain their phone directory efficiently while ensuring data integrity and confidentiality.

Uploaded by

alankrutha devu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

CSD110 - Design Specifications Doc - Sample 1

The document outlines the design specifications for a Python script that manages a personal phone directory, allowing users to add, search, update, and delete contacts. It includes user interaction details, programming methodology, and the structure of the code, which utilizes lists and a dictionary to store contact information. The script is intended for consumers looking to maintain their phone directory efficiently while ensuring data integrity and confidentiality.

Uploaded by

alankrutha devu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Course: CSD110

Introduction to Programming

Design Specs

Sample Doc

Student Name:
Student ID:
Write a Python script for the following scenario:

Create a program that stores and displays Personal Phone numbers:

Sample Output:

Welcome to My Friends Phone List

1. ………………..

2. ………………..

3. ……………….

4. Exit
DESIGN SPECIFICATIONS
Scope/Purpose: In this python script, ……………. The program accepts user input as
a number which maps to the following choices:
1. ………………….
2. ………………….
3. …………………
4. Exit
Methodology / Programming Sequence:
 Defined and initialized the list.
 The User is presented with 5 choices.
 The program is supposed to run 5 times (or till the user prefers to exit),
which keeps on prompting the user for more input till they exit the
program.
 The program also takes in one more input, ’n’ which holds the number of
contacts the program will be working on.
End user interaction:
 If the user selects the choice to Add contacts. A loop is started which runs
’n’ times. In each iteration it asks the user for a name and a number which
are then appended to the list1 and list2 defined at the start of the program
After adding this contact, this loop is repeated till user enters all the
contacts. Once all contacts are added, user is again taken back to the main
menu and shown all the choices and is asked for more input.

 If the user selects to Search for a contact, user is asked to enter the………
User is presented with an adequate message and is returned to the prompt.

 If the user selects to Update a contact, User is asked for a number to


update. If the name is not present, User is presented with an adequate
message and is returned to the prompt. If the name is present in the user is
taken back to the prompt.
 If the user selects to Delete a contact, user is asked for a name. If it is
present, the contact is deleted, and user is informed. Then the user is taken
back to the prompt.

End Users / Audience: This Python script’s target audience in a group of


consumers characterized by their behavior, interactions and choices made by
them listening to their requirements to add, delete, update, or search a record in
phone directory management system.
Goals: This Python script helps clients to produce high quality system which can
be performed in any situation to maintain the integrity and confidentiality of the
end user data. Client’s phone directory database is getting stored in dictionary,
from where its easy to pull all the alterations.
Source Code
Explanation
 First, I created a function called "show main menu" that has a menu with
five options: Add a contact, Search contact, Update contact, Delete
contact, and exit.
 I, then set the variable's initial value to ensure a programme iteration's
success. Second, I created two lists: lists 1 and 2 with the names.
 To basically store name and number, I made the list empty. Then I
initialised the Contact directory as a dictionary to hold the user-entered
record information.
 I used the function show main menu to retrieve the menu and inquire
about the user's selection based on the menu.
 After that, I initialised a variable called n, which prompts the user to specify
how many contacts they want to store in a dictionary.
 Then, using the range function up to 5, I constructed a for loop that would
allow me to iterate the programme for the menu above. I added an if
statement to the loop that checks to see if the user chooses to add a record
by selecting option 1.
 Then, I created a nested for loop using this reasoning, and it will continue to
do so until the value of n changes (which reflects how many contacts).
 There, I received two user inputs and stored them in the loop's name and
number variables. Then I added list 1 with the user-entered name and list 2
with the user-entered number. Then, I use the zip function to create lists 1
and 2 and the dictionary function to put all the data in a dictionary.
 Next, I created an elif condition for having choice 2, asking the user to enter
the name they wish to search for, and then based on their input, I created
an if condition that searches the user-supplied name in the dictionary and
prints “Contact found with the name and number” if the name is present. If
not, a suitable error message will be displayed.
 The user was then prompted to provide the name and number that (s)he
wanted to update as a requirement for choice 3.
 Furthermore, I inserted a condition for option 3 that asks the user to
provide the name and phone number that (s)he wants to change. If the
user-entered name already exists in the dictionary, the name and number
will be updated. If not, the message “No contact found” will appear.
 I then created an elif condition for option 4, which asks the user to specify
which contacts should be erased. The contact will be deleted if the name is
found in the dictionary. I delete the function and print a message for this.
 Option 5 (Exit or Quit) is the final selection. I just utilised the exit function.
 Overall, I added another condition that would cause an error message to
appear if the user entered incorrect data outside of the menu.
Output
Here, I’m taking input from the user to add the contact.
After having input from the user, I executed the code to perform the operation.
This successfully added the two new contacts along with their telephone numbers
in the Users Contact Management System (Personal Phone Book). This is
explained below:
Now, I perform the search operation. We can make search of any user which we
added in the above Add operation. This is explained below:

In continuation to above, I have performed the update operation to update a


contact in phone book:
Similarly, we can perform the delete operation and after making selection, it
deleted the contact successfully.

You might also like