Assignment | Console-based Program in Python 3

Added on - 18 Sep 2019

  • 7

    pages

  • 3311

    words

  • 108

    views

  • 0

    downloads

Showing pages 1 to 3 of 7 pages
CP1404/CP5632 2016 SP23/53 Assignment 1 –Reading List 1.0Task:You are to plan and then code a console-based program in Python 3, as described in the followinginformation and sample output. This assignment will help you build skills using selection, repetition,file input/output, exceptions, lists, functions and string formatting. Do not to define any of your ownclasses. Assignment 2 will build on this program with more advanced code constructs including classesand a Graphical User Interface (GUI). Work incrementally on this task: complete small parts of it at atime rather than trying to get it all working at once. Some requirements have in-text references like [0]that refer to the resources list near the bottom. Everything you need to know to complete thisassignment can be found in the subject materials.Program Overview:This program is a simple reading list that allows a user to track books they wish to read and books theyhave completed reading. The program maintains a list of books in a file, and each book has:title, author, number of pages, whether it is required or completed (r or c)Users can choose to see the list of required books or completed books, including a total of the numberof pages of the book list. The lists will be sorted by author then by number of pages (increasing).[1]Users can add new books and mark books as completed.They cannot change books from completed to required.Program Functionality Details:Ensure that your program has the following features, as demonstrated in the sample output below.Your program should:display a welcome message with your name in itdisplay a menu for the user to choose from[2]return to the menu after each action and loop until the user chooses to quiterror-check user inputs as demonstrated in the sample output[3]load a CSV (Comma Separated Values) file of books (just once at the very start); a sample CSVfile is provided for you and you must use this format[4]when the user chooseslist required:display a neatly formatted (lined up) list of all the requiredbooks with their details and a total of the number of pages of these books[3]when the user chooseslist completed:display a similarly formatted list of completed bookswhen the user choosesadd:prompt for the book’s title, author and number of pages,error-checking each of these, then add the book to the list in memory (not to the file)when the user choosesmark completed:display the list of required books (same as for list),then allow the user to choose one book (error-checked), then change that book to completedoif no books are required, then a "No books" message should be displayed and the userreturned to the menu (this is the same if there are no completed books)when the user choosesquit:save the books to the CSV file, overwriting the file contentsPlanning:Write up the algorithms in pseudocode for the two functions:load booksandcomplete a book.Do this in a docstring (comment) directly above each of these functions.At the very top of your code file, add a docstring containing yourname, date, brief program detailsanda link to your project on GitHub.Follow the guide to good pseudocode and examples presented in the subject to ensure this is done to ahigh standard.[5]You may show this part of the assignment to your tutor during practical time to getcomments or suggestions.You may do pseudocode for more than these two functions, but it is not required.CP1404/CP5632 SP2 Assignment 1 © 2016 – Information Technology @ James Cook University1/7
Coding Requirements and Suggestions:Make use of named constants where appropriate.Use functions appropriately for each significant part of the program: this is the divide-and-conquer problem-solving approach. Remember that functions should “do one thing”.Look for situations where functions can be used to reduce code duplication (e.g. when youdisplay the required lists and when you mark a book as completed – this is very similar).For efficiency, you shouldonly load the books file once. Store the results appropriately in a listof lists and pass that to any functions that need access to it. Note: this variable should not beglobal. The only global variables you may have are CONSTANTS.Note that the menu choice should handle uppercase and lowercase letters.Use exception handling where appropriate to deal with input errors (including entering numbersand selecting books). You should be able to use generic, customisable functions to performinput with error checking (e.g. getting the title and author can reuse the same function).Check the rubric carefully to see any other aspects of the coding that you will be assessed on.Output Requirements:Sample output from the program is provided below. Ensure that your program matches the sampleoutput including spaces, spelling, and especially the formatting of the book lists. Think of this ashelpful guidance as well as training you to pay attention to detail. The sample output is intended toshow the full range of situations including user input error handling.Submission:The assignment 'starter' will be provided to you via GitHub Classroom (see below). This will includethe books CSV file and a Python file called CP1404assignment1.pySubmitthisPython 3 (.py) code file containing your comments and pseudocode by uploading it onLearnJCU under Assessment (click on the title of the assignment).Git/GitHub:You must use Git version control and keep your project updated online in GitHub.If you have not yet created a GitHub account, do this now as explained athttps://github.com/CP1404/Starter/wiki/Software-Setup#githubYou must be easily identifiable from your GitHub username. Make sure you register for the studentdiscount so you get free private repositories:https://education.github.com/discount_requests/newYou are assessed on your use of version control including commits and commit messages, so commitregularly (each logical chunk or milestone) and use meaningful commit messages in the imperativevoice. Your commits should show steady work completed over reasonable time, not all in a shortperiod.Due:Submit your assignment bythe date and time specified on LearnJCU.Submissions received after this date will incur late penalties as described in the subject outline.Integrity:The work you submit for this assignment must be your own. You are allowed to discuss the assignmentwith other students and get assistance from your peers, but you may not do any part of anyone else’swork for them and you may not get anyone else to do any part of your work. Note that this means youshould never give a copy of your work to anyone or accept a copy of anyone else’s work. Submissionsthat are detected to be too similar to that of another studentwill be dealt with according to the Collegeprocedures for handling plagiarism and may result in serious penalties.If you require assistance with the assignment, please askgeneralquestions on the discussion forum, orgetspecificassistance with your own work by talking with your lecturer or tutor.CP1404/CP5632 SP2 Assignment 1 © 2016 – Information Technology @ James Cook University2/7
Sample Output:The following sample run was made using a CSV file that contained:The Practice of Computing Using Python,Punch and Enbody,792,rThe 360 Degree Leader,John Maxwell,369,rIn Search of Lost Time,Marcel Proust,365,cDeveloping the Leader Within You,John Maxwell,225,rBold greentext below shows user input for this sample.Reading List 1.0 - by Lindsay Ward4 books loaded from books.csvMenu:R - List required booksC - List completed booksA - Add new bookM - Mark a book as completedQ - Quit>>>rRequired books:0. Developing the Leader Within You by John Maxwell 225 pages1. The 360 Degree Leader by John Maxwell 369 pages3. The Practice of Computing Using Python by Punch and Enbody 792 pagesTotal pages for 3 books: 1386Menu:R - List required booksC - List completed booksA - Add new bookM - Mark a book as completedQ - Quit>>>cCompleted books:2. In Search of Lost Time by Marcel Proust 365 pagesTotal pages for 1 books: 365Menu:R - List required booksC - List completed booksA - Add new bookM - Mark a book as completedQ - Quit>>>mRequired books:0. Developing the Leader Within You by John Maxwell 225 pages1. The 360 Degree Leader by John Maxwell 369 pages3. The Practice of Computing Using Python by Punch and Enbody 792 pagesTotal pages for 3 books: 1386Enter the number of a book to mark as completed>>>oneInvalid input; enter a valid number>>>2That book is already completedMenu:R - List required booksC - List completed booksA - Add new bookM - Mark a book as completedQ - Quit>>>mRequired books:0. Developing the Leader Within You by John Maxwell 225 pages1. The 360 Degree Leader by John Maxwell 369 pages3. The Practice of Computing Using Python by Punch and Enbody 792 pagesTotal pages for 3 books: 1386Enter the number of a book to mark as completed>>>1The 360 Degree Leader by John Maxwell marked as completedMenu:R - List required booksC - List completed booksA - Add new bookM - Mark a book as completedCP1404/CP5632 SP2 Assignment 1 © 2016 – Information Technology @ James Cook University3/7