**Question 1**

(a) Implement a function generate_factors(y) that solves for all the factors of y. For example, for y = 20, your function is expected to return a list with values [2, 4, 5, 10].

(b) Given the following 5 test cases and print the results from your function.

Test Case 1 2 3 4 5

y 20 31 140 222 517

##### Hire a Professional Essay & Assignment Writer for completing your Academic Assessments

Native Best Writers Team

- 100% Plagiarism-Free Essay
- Highest Satisfaction Rate
- Free Revision
- On-Time Delivery

**Question 2**

You are required to implement your own sorting algorithm to sort a given list of numbers in an ascending manner. For example, given a list [4,3,2,1], you are suggested to:

1. Start with the first item in the list x, compare it with the number that is next to it, i.e. compare the number x[i] with x[i + 1]

2. If the two numbers are not in the right order, swap their positions. If they are, keep the number in their original positions.

3. Continue the comparison until you have reached the end of the list, i.e. the second-to-last item in the list

4. Repeat Step 1. The algorithm can be stopped when there is no more swapping of numbers as you iterate through the list.

For the given list of [4,3,2,1], the figure below shows the evolution of the sorted list as it goes through the algorithm:

[4,3,2,1] → [3,4,2,1] → [3,2,4,1] → [3,2,1,4]

[3,2,1,4] → [2,3,1,4] → [2,1,3,4] → [2,1,3,4]

[2,1,3,4] → [1,2,3,4] → [1,2,3,4] → [1,2,3,4]

[1,2,3,4] → [1,2,3,4] → [1,2,3,4] → [1,2,3,4]

A total of 12 steps is required to evolve from the unsorted list to the sorted list.

(a) Formulate a function sorting_function(k) that sort the list k. The outputs of your functions must include the sorted k and the number of steps required to sort k.

(b) Given the following 5 test cases, print the results from your function:

**Question 3**

You are required to work out the periodic investment amount required given a target wealth to be achieved sometime in the future. For example, with an annual investment return of 2.5%, a monthly investment amount is $2,403 will yield a final wealth of $1,000,000 in 2 years’ time.

You are recommended to make use of existing python functions within your function to evaluate the required values.

(a) Implement a function contribution_calculator(target_wealth, rate, duration, periodicity) that will inform an investor of the periodic contribution required in order to fulfil her financial goal.

(b) Given the following 5 test cases, print the results from your function.

**Question 4**

It is common that there are missing data in a dataset, and you wish to automate the clean-up of missing data by using Python. Given a price dataset, implement and detect the presence of missing price data.

(a) Write a function that clears up missing data if the missing data is denoted by -99. If a missing price is detected, it is replaced by taking the average of the prices immediately adjacent to the missing price.

You can only replace the missing price with the average value if and only if the adjacent prices are valid data. If you cannot calculate the average price, the mission price is replaced by the adjacent price which has a valid value.

Inform the user that the price data has been cleaned up by there is any replacement of the missing price. State any assumptions, if any, you have made in your function implementation.

(b) Use your function on the following test cases:

For each of the test cases, you are required to print the original dataset, the clean-up dataset and if there was any replacement of missing data.

##### Buy high-quality essays & assignment writing as per particular university, high school or college by Best Writers

**CLICK HERE TO GET A PROFESSIONAL WRITER TO WORK ON THIS PAPER AND OTHER SIMILAR PAPERS**