Recent Question/Assignment
Assignment 1
Mailing List Maintenance
The goal here is to write some software that would assist a system administrator to maintain a list of email addresses. The assignment will get progressively more complex as it proceeds - the early stages will be reasonable straight forward and will be sufficient for a passing grade, and the more advanced stages are for those who wish to go further and target a higher overall result.
General Requirements
All assignments should be written in Python 3 and should run in IDLE. They can be written on any type of computer, but they should be able to be executed in the computer pools.
The highest marks will be for working code. However, in cases where there are problems, you will be assigned marks for how you approached the task. It is also expected that you will provide comments in the programs to explain how it works, and this will account for up to 10% of the overall grade.
Stage 1: Data Entry
Write a program which requests that the user enters a name and email address. Store that data in a List. After the user has entered data, request that the user enters Y or N to continue. If they enter N, print the list of names and email addresses to the screen. If they enter Y, repeat the first step.
Your program should produce the following result:
Mailing List Manager
Enter a name: Gaye Deegan
Enter an email address: gaye.deegan@unisa.edu.au
Gaye Deegan at gaye.deegan@unisa.edu.au has been recorded.
Do you wish to enter another account? (Y/N) Y
Enter a name: Ben Martini
Enter an email address: ben.martini@unisa.edu.au
Ben Martini at ben.martini@unisa.edu.au has been recorded.
Do you wish to enter another account? (Y/N) N
1. Gaye Deegan: gaye.deegan@unisa.edu.au
2. Ben Martini: ben.martini@unisa.edu.au
Thankyou.
Stage 2: Validation
Building on stage 1, you now need to ensure that the program checks for valid entries in each case, and converts the text to the appropriate format.
You need to:
• Ensure that a name and email address was entered, If either the name or email is empty, do not record that item and go straight to asking if they wish to continue.
• Convert the name to title case, and the email to lower case.
• Ensure that the user enters either -Y-, -y-, -N- or -n- when asked if they wish to continue. Continue to ask until they enter a valid result.
• For extra marks, ensure that the email contains an -@- sign. This was not covered in the course, so will require extra research. If it does not contain -@-, as the user to enter the email again.
Sample output:
Mailing List Manager
Enter a name: Gaye Deegan
Enter an email address: gaye.deegan@unisa.edu.au
Gaye Deegan at gaye.deegan@unisa.edu.au has been recorded.
Do you wish to enter another account? (Y/N) yes
Do you wish to enter another account? (Y/N) y
Enter a name:
No record has been recorded.
Do you wish to enter another account? (Y/N) Y
Enter a name: BEN MARTINI
Enter an email address: Ben.Martini.unisa.edu.au
Enter an email address: Ben.Martini@unisa.edu.au
Ben Martini at ben.martini@unisa.edu.au has been recorded.
Do you wish to enter another account? (Y/N) N
1. Gaye Deegan: gaye.deegan@unisa.edu.au
2. Ben Martini: ben.martini@unisa.edu.au
Thankyou.
Stage 3: Objects and Persistance
This involves two separate jobs:
• Create a class to store the details of the account rather than using a List on its own. Employ the Class in your code.
• Store the account details in a text file, and load then when next the program is launched.
Sample Output
Mailing List Manager
Enter a name: Gaye Deegan
Enter an email address: gaye.deegan@unisa.edu.au
Gaye Deegan at gaye.deegan@unisa.edu.au has been recorded.
Do you wish to enter another account? (Y/N) N
1. Gaye Deegan: gaye.deegan@unisa.edu.au
Thankyou.
Mailing List Manager
Enter a name: Ben Martini
Enter an email address: ben.martini@unisa.edu.au
Ben Martini at ben.martini@unisa.edu.au has been recorded.
Do you wish to enter another account? (Y/N) N
1. Gaye Deegan: gaye.deegan@unisa.edu.au
2. Ben Martini: ben.martini@unisa.edu.au
Thankyou.
Stage 4: Options and CSV
In this stage we need to add an optional -Export to CSV- option, along with the ability to choose to list existing entries and/or add a new one. The program should now ask the user to choose between 4 options: Add a new account, List existing accounts, Export to CSV, or Quit. If they do not choose one of those four options, they need to be asked again. If they choose Export, we need to output the data to accounts.csv. Otherwise we need to add, list or quite as required.
Now that things are getting more complex, you are expected to use functions to manage these tasks in your program.
Sample output:
Mailing List Manager
-----
(A)dd a new account
(L)ist existing accounts
(E)xport to CSV
(Q)uit
Your choice: A
Enter a name: Gaye Deegan
Enter an email address: gaye.deegan@unisa.edu.au
Gaye Deegan at gaye.deegan@unisa.edu.au has been recorded.
-----
(A)dd a new account
(L)ist existing accounts
(E)xport to CSV
(Q)uit
Your choice: L
1. Gaye Deegan: gaye.deegan@unisa.edu.au
-----
(A)dd a new account
(L)ist existing accounts
(E)xport to CSV
(Q)uit
Your choice: a
Enter a name: Ben Martini
Enter an email address: gaye.deegan@unisa.edu.au
Ben Martini at gaye.deegan@unisa.edu.au has been recorded.
-----
(A)dd a new account
(L)ist existing accounts
(E)xport to CSV
(Q)uit
Your choice: e
Accounts saved as accounts.csv.
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: Q
Thankyou.
Stage 5: Deleting and Updating
For the last stage we need to make this a bit more general purpose by introducing methods to delete and update records. As we're doing this, we will also need to record when events happen. Accordingly, you will need to add:
• A date/time created property in the account.
• A date/time updated property in the account.
• An ability to delete a record, where the user enters the ID (number) of the record and it is removed after confirming the record with the user. You will need to learn how to delete an item from a List and to update the save file.
• The ability to edit a record by changing the email address. As with delete, the user will need to specify the ID of the record to be edited. If no ID is specified, or if the ID is incorrect, it will not continue.
Sample output:
Mailing List Manager
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: A
Enter a name: Gaye Deegan
Enter an email address: gaye.deegan@unisa.edu.au
Gaye Deegan at gaye.deegan@unisa.edu.au has been recorded.
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: l
1. Gaye Deegan: gaye.deegan@unisa.edu.au
Created: Tuesday, 05. September 2017 07:25AM
Updated: Tuesday, 05. September 2017 07:25AM
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: d
Enter record ID: 1
You are about to delete Gaye Deegan: gaye.deegan@unisa.edu.au
Do you wish to delete this record (Y/N): N
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: d
Enter record ID: 1
You are about to delete Gaye Deegan: gaye.deegan@unisa.edu.au
Do you wish to delete this record (Y/N): Y
Record deleted.
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: l
No records to display
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: a
Enter a name: Ben Martini
Enter an email address: gaye.deegan@unisa.edu.au
Ben Martini at gaye.deegan@unisa.edu.au has been recorded.
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: l
1. Ben Martini: gaye.deegan@unisa.edu.au
Created: Tuesday, 05. September 2017 07:30AM
Updated: Tuesday, 05. September 2017 07:30AM
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: C
Enter record ID: 2
There are no records with the ID -2-.
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: C
Enter record ID: 1
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: C
Enter record ID: 1
Enter an email address: ben.martini@unisa.edu.au
Ben Martini at ben.martini@unisa.edu.au has been updated.
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: l
1. Ben Martini: gaye.deegan@unisa.edu.au
Created: Tuesday, 05. September 2017 07:30AM
Updated: Tuesday, 05. September 2017 07:32AM
-----
(A)dd a new account
(L)ist existing accounts
(C)hange email address
(D)elete an account
(E)xport to CSV
(Q)uit
Your choice: Q
Thankyou.