DD.04 :Design document: Follow the instructions in A/DD.04 and record your desig

WRITE MY ESSAY

DD.04 :Design document:
Follow the instructions in A/DD.04 and record your designs for each of the problems in your Design Document. Make sure to:
List each design in a clearly marked section indicates which question the design belongs to.
For each design make sure to note any details about the question that are relevant to your design, such as the inputs, outputs, any required displays.
Also make sure to detail your tests including all inputs and outputs you’d expect to see.
Each problem should have a detailed plan which outlines step-by-step how you get the required outputs from the provided inputs.
If you divide any problem into smaller algorithms, make sure to detail all of the information for those designs as well.
As a rule of thumb, your designs should include enough detail that anyone else could take your design and implement the same solution without confusion. If you’re questioning if a design is clear enough, ask a TA if they understand your work!
A.04: assignment:
Follow the instructions in A/DD.04 and once done with your design implement each required function in this assignment. Use the Python Template in the course Toolbox to start your implementation.
Make sure to follow all course guidelines!
# TODO; My functions
def main():
# TODO; Test my functions
pass
if __name__ == “__main__”:
main()
A/DD.04:Question 1: List Utilities
Design and implement the following functions:
copy_list: which takes a list and returns a copy of that list.
Inputting ([a, b, c, d]) would result in something that looks like ([a, b, c, d])
reverse_list: which takes a list and returns a new list that is reversed.
Inputting ([a, b, c, d]) would result in something that looks like ([d, c, b, a])
modify_list: which takes a number and a list of numbers and returns a new list containing the first number added to each of the items.
Inputting (a, [b, c, d]) would result in something that looks like [a+b, a+c, a+d]
combine_lists: which takes in two lists and returns another list that contains the sum of all indices that were possible.
Inputting ([a,b,c], [d,e,f,h]) would result in something that looks like [a+d, b+e, c+f]
Question 2: Blackjack
In the game of Blackjack, the goal is to get a score as close as possible to 21. To “bust” is to go over this value. Design the algorithm blackjack that takes a “hand” as a list of integers representing the cards in a deck, from 1 to 11, and displays the total of the cards in that hand. If the hand busts, show a message indicating the one-indexed place of the card in the hand caused the total to go over. If there are any illegal cards in the hand, print “Cheating!” and immediately return.
Examples for Question 2Input
Display
[1, 2, 10, 3, 5]
Total: 21
[4, 4, 5]
Total: 13
[]
Total: 0
[6, 4, 10, 10, 3]
Total: 33 is a bust! Blame card 4.
[1, 2, 10, 3, 5, 2]
Total: 23 is a bust! Blame card 6.
[1, 2, 12, 4]
Cheating!
Question 3: Merging Lists
Design and implement the function merge_lists, which takes two sorted lists of integers and outputs a single sorted list of integers containing all the values in the inputs. Your algorithm must be able to take any two independently sized lists and merge them, even if there are duplicates! Consider the following non-exhaustive list of edge cases you might have to consider:
Examples for Question 3Input A
Input B
Output
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]
[1, 1, 2, 2, 3, 3, 4, 4, 5, 5]
[1, 2, 3]
[4, 5]
[1, 2, 3, 4, 5]
[-10, 6, 12]
[-4, 0, 0, 4]
[-10, -4, 0, 0, 4, 6, 12]
[2, 4, 8, 8, 10]
[5, 6, 8, 10, 11]
[2, 4, 5, 6, 8, 8, 8, 10, 10, 11]
Question 4: Lists of Instructions
Create a function sum_indices, which takes a list of integers and a list of floats and computes the sum of values from the second list as indicated by the indexes in the first list. In other words, the first list contains all the indexes in the second list that your algorithm should use to compute the final sum.
The integers in the first list are not unique and can include any integer. To prevent your algorithm from crashing, when there is an out-of-bounds index, immediately return 0 and display a message with the index that caused the error.
Examples for Question 4Input A
Input B
Output
[1,0,3,1]
[1.0, 2.0, -3.0, 4.0]
9.0
[2, 2, 1]
[3.4, 5.6, 7.0]
19.6
[]
[3.0, 1.0, -4.0]
0.0
[3, 2, 5]
[4.2, 5.6, 3.1, 3.0]
0.0
Extra: Windowed Average (+3/1.5)
This is an extra credit problem that will add (3) points to DD.04 and (1.5) points to A.04 for total bonus of (+15%) and (+15%), respectively. This is a difficult problem but can be done using all of the tools we’ve gathered so far.
The windowed average is an operation that we can apply to a list of numbers to compute localized averages. This is done by summing the ‘window’ of the ‘n’ elements surrounding some index and then shifting that window to the right until it cannot shift any more. Consider the graphic below which shows and example of this when n=1 for a list of length five.
Consider for a moment what it would mean to when n=0. Using the example above, it would be the average of zero items to the left and right and essentially copy the list. Similarly, n=2 would be an average of the entire list, resulting in a list of size one.
For this problem, design and implement a algorithm that computes the n-windowed average of a list of numbers called windowed_average. It should take an integer as the ‘n’ along with a list of floating point numbers and it should output the computed windowed average as a list. The signature of this function would then look as follows:
def windowed_average(n, lst):
…If a window is too big, this means there wasn’t enough to average and you should return an empty list. Check that ‘n’ is a valid integer and return an empty list if it is not.
No partial points will be given. To receive credit for this problem you must:
Provide a Data Flow Diagram of your algorithm in your design document along with your test cases.
Submit a valid implementation that works for all possible inputs.
Some things to note:
The Ag will only provide general feedback on if your algorithm conformed to course policies.
Staff cannot help with implementation details or understanding the problem, however, working on the design with your fellow classmates is heavily encouraged.

WRITE MY ESSAY

Leave a Comment

Scroll to Top