Assignment 1 – Albums 1.0
Task:
Write a Python (3) program, as described in the following information and sample output. This assignment will help you build skills using decisions, repetition, file input/output, exceptions, lists, functions and string formatting. Do not define any of your own classes or use constructs that have not been taught in this subject. Assignment 2 will build on this with more advanced constructs including dictionaries, classes and a Graphical User Interface (GUI).
Some requirements have in-text help references, like [0], that refer to the resources list near the bottom of this document. Please check these references to find help on that topic. Everything you need to complete this assignment can be found in the subject materials.
Use and modify the starter files provided. Do not add any other files, and do not rename anything - just use this as your assignment directory.
Problem Description:
This program allows a user to track music albums they want to listen to (required) and albums they have already listened to (completed). The program reads and writes a list of albums in a text file. Each album has:
• title, artist, year released, whether it is required (r) or completed (c)
Users can choose to display the list of albums , which will be sorted by artist, then by title. [1]
Did you see that reference? Look below for [1] and you’ll find out where we have taught you how to sort lists by multiple keys.
Users can add new albums and mark albums as completed.
They cannot change albums from completed to required.
As demonstrated in the sample output below, your program should:
- display a welcome message with your name
- display a menu for the user to choose from [2, 3]
- error-check user inputs (see sample output for example checks and outputs) [4]
- load a CSV (Comma Separated Values) file of albums (just once at the very start); a sample CSV file is provided for you and you must use this format [5] (note: you're not expected to use the csv module, but you're welcome to)
- when the user chooses list: display a neatly formatted (lined up) list of all the albums with their details and the number of albums you need to listen to [4]. Required albums have a * next to them. Note that the lining up is based on the longest title and artist [6]
- when the user chooses add: prompt for the album’s title, artist and year, error-checking each of these [3], then add the album to the list in memory (not to the file); new albums are always required
- when the user chooses mark completed: display the list of all albums (same as for the list option), then allow the user to choose one album (error-checked), then change that album to completed
o if there are no required albums, then "No required albums" should be displayed
- when the user chooses quit: save the albums to the CSV file (note that this should be the only time that the file is saved)
Sample output from the program is provided below. Ensure that your program matches this, including spaces, spelling, and the formatting of the album lists. Think of this as helpful guidance as well as training you to pay attention to detail. The sample output is intended to show a large (but maybe not exhaustive) range of situations including user input error handling.
Coding Requirements and Expectations:
- Makeuseofnamedconstantsasappropriate(e.g.,forthecharactersthatrepresent the album's required/completed status).
- Usefunctionsappropriatelyforeachsignificantpartoftheprogram.Followprinciples you've learned about functions, including the single responsibility principle (SRP).
- Onlyload(read)thealbumsfileonce, whentheprogramstarts.
- Onlysave(write)thealbumsfileonce, whentheprogramends.
- Storethealbumdatainalistoflistsandpassthattoanyfunctionsthatneedaccess to it. Note: this variable should not be global. The only global variables you may have are CONSTANTS. (Did you understand this? If you use global variables, your functions will be poorly designed. Do not use any global variables.)
- Donotstoreanalbum'sindex/number–thisisjustbasedonitspositioninthelist.
- Themenuchoiceshouldhandleuppercaseandlowercaseletters.
- Useexceptionhandlingwhereappropriatetodealwithinputerrors(includingentering numbers and selecting albums). You should be able to use generic, customisable functions to perform input with error checking (e.g., getting the album title and artist can reuse the same function).
- Theoutputshowsthatthesolutiondoesnotrequirecorrectplurals(e.g.,"1albums"). You are welcome to leave yours this way. You may add logic to print these statements correctly, but it is not expected or assessed.
We strongly suggest you work incrementally on this task: focus on completing small parts rather than trying to get everything working at once. This is called "iterative development" and is a common way of working, even for professionals.
Check the rubric below carefully to understand how you will be assessed. There should be no surprises here – this is about following the best practices we have taught in class.
Submission:
Zip up your project directory as it is, then submit this zip file. Ensure that you do NOT include a venv (virtual environment). Name the file like: FirstnameLastnameA1.zip. Upload your single zip file to the assignment submission on your subject website.
Due:
Submit your assignment by the date and time specified. Submissions received after this date will incur late penalties.
Sample Output:
The following sample run was made using a CSV file that contained:
The Dark Side of the Moon,Pink Floyd,1973,r Common Jasmin Orange,Jay Chou,2004,r
After the Music Stops,Lecrae,2006,c Honey,Lay,2019,c
You should be able to figure out what parts of the sample output below are user input.
Albums 1.0 - by Lindsay Ward 4 albums loaded
Menu:
L - List all albums
A - Add new album
M - Mark an album as completed Q - Quit
>>> user input here
Invalid menu choice
Menu:
L - List all albums
A - Add new album
M - Mark an album
Q - Quit
>>> l
*1. Common Jasmin
2. Honey
3. After the Music Stops
*4. The Dark Side of the Moon You need to listen to 2 albums. Menu:
L - List all albums
A - Add new album
M - Mark an album
Q - Quit
>>> m
*1. Common Jasmin
2. Honey
2. Honey
by Jay Chou by Lay
by Lecrae
by Pink Floyd
3. After the Music Stops
*4. The Dark Side of the Moon You need to listen to 2 albums. Menu:
L - List all albums
A - Add new album
M - Mark an album
Q - Quit
>>> m
*1. Common Jasmin
2. Honey
You need to listen to 1 albums. Menu:
L - List all albums
A - Add new album
M - Mark an album as completed Q - Quit
3. After the Music Stops
*4. The Dark Side of the Moon
You need to listen to 2 albums.
Enter the number of an album to mark as completed >>> incorrect
Invalid input; enter a valid number
>>> -2
Number must be > 0
>>> 0.2
Invalid input; enter a valid number
>>> 0
Number must be > 0
>>> 3
You have already listened to After the Music Stops Menu:
L - List all albums
A - Add new album
M - Mark an album
Q - Quit
>>> L
*1. Common Jasmin
References – Resources from Subject Materials:
Selected subject materials are referenced here to help you find guidance for specific parts of the assignment (e.g., sorting a list by multiple values is covered in [1] and you will find a template for writing menus for console programs in [2]).
General references are not listed specifically but should be obvious (e.g., file input/output is covered in the lecture and practical on files).
You should find the programming patterns "cheat sheet" helpful for several things. This is provided on GitHub or as a PDF in your subject website: https://github.com/CP1404/Starter/wiki/Programming-Patterns
- itemgetter from Chapter 7 - Lists and Tuples.
- Practical 01 - PyCharm, Control.
https://github.com/CP1404/Practicals/tree/master/prac_01
- Programming Patterns. https://github.com/CP1404/Starter/wiki/Programming-Patterns
- Practical 02 - Strings, Files, Exceptions.
https://github.com/CP1404/Practicals/tree/master/prac_02
- Chapter 5 - Files and Exceptions 1.
- Practical 05 - Dictionaries, Code Reviews with PRs.
https://github.com/CP1404/Practicals/tree/master/prac_05
- Negotiating the Maze of Academic Integrity in Computing Education.
https://dl.acm.org/citation.cfm?doid=3024906.3024910