python coding assistance for part 2
**Click once—type in course code—do not use return key** (2004) COMP 1039 Problem Solving and Programming Programming Assignment 2 School of Computer and Information Science The University of South Australia October, 2020 2 of 31 Contents Introduction Assignment Overview Graduate Qualities Part I Specification Practical Requirements (Part I) Stages (Part I) Part II Specification Practical Requirements (Part II) Stages (Part II) Submission Details Extensions and Late Submissions Academic Misconduct Marking Criteria Sample Output – Part I Sample Output – Part II Useful Built-In Python Functions – required for part II 3 of 31 INTRODUCTION This document describes the second assignment for Problem Solving and Programming. The assignment is intended to provide you with the opportunity to put into practice what you have learnt in the course by applying your knowledge and skills to the implementation of a Python module (that contains functions that operate on lists) and a program that will maintain information on characters (heroes and villains). This assignment is an individual task that will require an individual submission. You will be required to submit your work via learnonline before Tuesday 10 November (swot vac), 10:00 am (internal students). This document is a kind of specification of the required end product that will be generated by implementing the assignment. Like many specifications, it is written in English and hence will contain some imperfectly specified parts. Please make sure you seek clarification if you are not clear on any aspect of this assignment. ASSIGNMENT OVERVIEW There are two parts to this assignment: Part I: Writing a Python Module (list manipulation functions) You are required to implement a Python module that contains functions that manipulate lists. Please ensure that you read sections titled 'Part I specification' below for further details. Part II: Manage character (hero and villain) information You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in when the program commences. Once the initial character (hero and villain) information has been read in from the file, the program should allow the user to interactively query and manipulate the character (hero and villain) information. Please ensure that you read sections titled 'Part II specification' below for further details. Please ensure that you read sections titled ‘Part I Specification’ and ‘Part II Specification’ below for further details. 4 of 31 GRADUATE QUALITIES By undertaking this assessment, you will progress in developing the qualities of a University of South Australia graduate. The Graduate qualities being assessed by this assignment are: The ability to demonstrate and apply a body of knowledge (GQ1) gained from the lectures, workshops, practicals and readings. This is demonstrated in your ability to apply problem solving and programming theory to a practical situation. The development of skills required for lifelong learning (GQ2), by searching for information and learning to use and understand the resources provided (Python standard library, lectures, workshops, practical exercises, etc); in order to complete a programming exercise. The ability to effectively problem solve (GQ3) using Python to complete the programming problem. Effective problem solving is demonstrated by the ability to understand what is required, utilise the relevant information from lectures, workshops and practical work, write Python code, and evaluate the effectiveness of the code by testing it. The ability to work autonomously (GQ4) in order to complete the task. The use of communication skills (GQ6) by producing code that has been properly formatted; and writing adequate, concise and clear comments. The application of international standards (GQ7) by making sure your solution conforms to the standards presented in the Python Style Guide slides (available on the course website). 5 of 31 PART I SPECIFICATION – WRITING A PYTHON MODULE (LIST MANIPULATION FUNCTIONS) You are required to write a list_function.py module (containing only the functions listed below). This file is provided for you (on the course website) however, you will need to modify this file by writing code that implements the functions listed below. Please read the slides on modules available on the course website if you would like more information on modules. You are required to implement a Python module containing the following functions: 1. Write a function called length(my_list) that takes a list as a parameter and returns the length of the list. You must use a loop in your solution. You must not use built-in functions, list methods or string methods in your solution. 2. Write a function called to_string(my_list, sep=', ') that takes a list and a separator value as parameters and returns the string representation of the list (separated by the separator value) in the following form: item1, item2, item3, item4 The separator value must be a default argument. i.e. sep=', ' You must use a loop in your solution. You must not use built-in functions (other than the range() and str() functions), slice expressions, list methods or string methods in your solution. You may use the concatenation (+) operator to build the string. You must return a string from this function. 3. Write a function called find(my_list, value) that takes a list, and a value as parameters. The function searches for the value in the list and returns the index at which the first occurrence of value is found in the list. The function returns -1 if the value is not found in the list. 4. Write a function called insert_value(my_list, value, insert_position) that takes a list, a value and an insert_position as parameters. The function returns a copy of the list with the value inserted into the list (my_list) at the index specified by insert_position. Check for the insert_position value exceeding the list (my_list) bounds. If the insert_position is greater than the length of the list, insert the value at the end of the list. If the insert_position is less than or equal to zero, insert the value at the start of the list. You must use a loop(s) in your solution. You may make use of the list_name.append(item) method in order to build the new list. You must not use built-in functions (other than the range() function), slice expressions, list methods (other than the append() method) or string methods in your solution. 5. Write a function called remove_value(my_list, remove_position) that takes a list and a remove_position as parameters. The function returns a copy of the list with the item at the index specified by remove_position, removed from the list. Check for the remove_position value exceeding the list (my_list) bounds. If the remove_position is greater than the length of the list, remove the item at the end of the list. If the remove_position is less than or equal to zero, remove the item stored at the start of the list. You must use a loop in your solution. You may make use of the list_name.append(item) method in order to build the new list. You must not use built-in functions (other than the range() function), slice expressions, list methods (other than the append() method) or string methods in your solution. 6. Write a function called get_slice(my_list, start, stop) that takes a list, a start value and a stop value as parameters. The function returns a copy of the list between start and stop-1 (inclusive). Check for the start and stop values exceeding the list bounds. If the stop value exceeds the list bounds, then make the stop value the length of the list. If the start value exceeds the list bounds, then make the start value zero (0). Check for the start value being less than the stop value. If the start value is greater than the stop value, return an empty list. You must use a loop in your solution. You may make use of the list_name.append(item) method in order to build the new list. You must not use built-in functions (other than the range() function), slice expressions, list methods or string methods in your solution. Please note: You must test your functions to ensure that they are working correctly. So you do not have to write your own test file, one has been provided for you. The assign2_partI_test_file.py file is a test file that contains code that calls the functions contained in the list_function.py module. Please do not modify the test file. 6 of 31 PRACTICAL REQUIREMENTS (PART I) It is recommended that you develop this part of the assignment in the suggested stages. It is expected that your solution WILL include the use of: The supplied list_function.py module (containing the functions listed below). This is provided for you – you will need to modify this file. Functions (length, to_string, find, insert_value, remove_value and get_slice) implemented adhering to the assignment specifications. The supplied assign2_partI_test_file.py file. This is provided for you – please DO NOT modify this file. Well constructed while loops. (Marks will be lost if you use break statements or the like in order to exit from loops). Well constructed for loops. (Marks will be lost if you use break statements or the like in order to exit from loops). Appropriate if/elif/else statements. Output that strictly adheres to the assignment specifications. Good programming practice: o Consistent commenting and code layout. You are to provide comments to describe: your details, program description, all variable definitions, all functions, and every significant section of code. o Meaningful variable names. Your solutions MAY make use