[SOLVED] 代写 python graph Skip navigation

30 $

File Name: 代写_python_graph_Skip_navigation.zip
File Size: 329.7 KB

SKU: 0862437428 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


Skip navigation


PROGRAMMING FOR SCIENTISTS S2 2019
ANU College of Engineering & Computer Science

COMP1730/6730
Course content & schedule
Labs
Assessment
Archive

1.Home » COMP1730/6730: Assessment » Homework 4 (S2 2019)
Homework 4 (S2 2019)
Homework 4 (S2 2019)
This is the fourth homework assignment. Your goal in this assignment is to write a function that performs a calculation on sequence data and returns a value. For this homework, like the previous two, we provide you with a testing framework, which will run tests of your function. It is important that you learn to use the testing program effectively, since we will be using this kind of automated testing for the remaining homework as well as in the exams.
Your solution to this homework will also be marked on code quality. This means some part of the marks will be given for good functional decomposition, variable/function naming, and commenting. The marks for code quality are distinct from those for functionality; to gain full marks, your submission must be both functional and readable.
Practical information
The assignment is due 11.55pm on Monday in semester week 8. That is, the Monday of the second week after the teaching break (the 23rd of September). To submit your solution, you will upload a single python file via wattle. Here is the assignment submission link.
Note: We have postponed the submission due date and in-lab assessment of Homework 4 by one week from what was originally advertised. Because of this, we will offer any student who wants to have their homework 4 assessed in their week 7 lab the option to do so; however, if you want to have your homework assessed in the lab in week 7, you must submit it before 11.55pm on the Monday of week 7 (the 16th of September).
In addition to submitting your solution, you must attend the following lab (in week 8). In the lab, your tutor will ask you some questions about your solution, and give you feedback if there is anything you need to improve. This discussion with the tutor is also part of the assessment.
If you fail to show up for the discussion with the tutor, you will receive zero marks for this assignment. If you do not submit a solution, you may still get partial marks for the discussion with the tutor.
The homework is individual. You must write your own solution, and you are expected to be able to explain every aspect of it.
As usual, you should have followed last week’s lectures and worked through the exercises in lab 4 and lab 5 before starting on the assignment. The assignment should not take more than one or two hours to complete.
The problem
The graph below shows the evolution of the price of one bitcoin over 30 days:

As you would expect, the price fluctuates over time. To make money in a speculative market, one should of course buy when the price is low, and sell when it is high. With the benefit of hindsight (or perfect foresight), i.e., knowing the price evolution over an interval of time, we can calculate what is the biggest profit that could be made (proportionally to the amount invested) by finding the two points with the biggest increase. However, these can not be any two points: the low point must come before the high point. For example, in the graph above, the highest price ($8235.70) occurred on the 28th of July, and the lowest point ($6139.99) occurred on the 10th of August, so it would not be possible to buy at the lowest price and sell at the highest. The maximum increase that we can find, in this example, is from $6139.99 on August 10th to $6729.44 on August 25th, an increase of $589.45.
Of course, we can do the same calculation on a series that does not represent money. For example, the enrolments in COMP1730/6730 from 2013 to the current year are
226, 264, 337, 364, 485, 529, 482
The biggest increase is from the first element to the second last, a total of 303.
Write a function max_increase(seq) which takes as argument a sequence of numbers and returns the maximum increase from one element in the sequence to an element at a higher index.
Assumptions and restrictions:
•The function must return a number.
•If there is no increasing pair in the sequence, the function should return 0. This may happen for example if the sequence is decreasing, or if it contains fewer than 2 elements.
•You can assume that the argument is a sequence, and that its elements are numbers (integer or decimal), but other than that you should not make any assumptions. In particular, you should not assume that it is any particular type of sequence (list, array, etc) and use only operations that are applicable to all sequence types.
As a starting point, we provide you with a skeleton code file: max_increase.py. Download this file and write in it your implementation of the function.
Testing
The skeleton file has a testing function: test_max_increase(). It runs some tests on max_increase function, and will raise an error if any of the tests fail. If all tests pass, each testing function prints the message “all tests passed” at the end.
Remember that testing only checks a small number of predefined cases; it can never prove that your function works correctly for all valid arguments. You should examine the test cases that are provided, and think about whether there are any important ones that are missing.
Note that you can define additional functions, if you think it helps you decompose the problem or write a better solution. Your function definitions should contain docstrings, but you may not use strings as comments anywhere other than on the first line inside a function, or at the beginning of the file.
Marking
Code quality
In this homework (like in the last one) we will also be marking your submission for its code quality. This includes aspects such as:
•Using good function, parameter and variable names. The names of some functions in the homework are fixed, but if you define additional functions (to decompose the problem) then they should be given descriptive names.
•Appropriate use of comments and docstrings.
This means not too little comments but also not too much. Comments should be accurate, relevant, and readable. A docstring should appear as the first statement in every function definition.
•Good code organisation.
This includes appropriate use of functions to decompose a problem and avoid code repetition. Also, do not import modules that you do not use.
What to submit
You should edit the skeleton file max_increase.py, then upload only this file with your implementation of the function using the assignment submission link on wattle.
Remember that you must upload a single python code file. Do NOT zip it or convert it to another format.
The file that you submit must meet the following requirements:
•It must be syntatically correct python code.
•Like the file you downloaded, it should contain only function definitions, and, optionally, import statements. However, it is not necessary to use any module to solve the problem, and you should only import modules that you actually use. Comments, including docstrings (if they are used appropriately) are of course ok to include. Anything that is not a function definition or import statements will be ignored when we check your submission.
As mentioned above, you must also attend the following lab and answer your tutor’s questions about your solution. This discussion is part of the assessment. You should be prepared to answer or demonstrate to the following questions:
•Can you download the file that you submitted from wattle?
•Can you run that file in the python interpreter (using an IDE of your choice) on the CSIT lab computer?
•If the file has syntax errors, can you use the error messages from the interpreter or IDE to identify where the syntax errors are?
•Does your submitted file meet the requirements stated above? Does it contain anything that is not a function definition? If so, can you point it out?
•Does your implementation pass all the tests run by the unmodified testing function?
•Is your implementation of the function correct for any valid argument sequence?
•Do your functions always return a value of the correct type?
•Did you think of any other test cases that should be used to test your function, in addition to or in place of those provided?
•What is the difference between the print function and the return statement?
In marking this assignment we will consider the following:
•Does your submitted file satisfy the requirements specified above?
•Does your implementation compute the correct value for all valid arguments?
•The quality of your submitted python code, including its organisation, naming and documentation (with docstrings and comments).
•Your ability to use the tools (e.g., the IDE or python interpreter), your understanding of python’s error messages, and your understanding of the solution, as demonstrated in your discussion with the tutor.
The assignment is worth 4% of your final mark. 2 marks are based on the functionality of your submission, and 2 mark on the quality and readability of your code.
Updated:  25 Sep 2019
Responsible Officer:  Head of School
Page Contact:  Patrik Haslum
Contact ANU
Copyright
Disclaimer
Privacy
Freedom of Information
+61 2 6125 5111
The Australian National University, Canberra
CRICOS Provider : 00120C
ABN : 52 234 063 906



Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 python graph Skip navigation
30 $