Month: February 2017

Sample Screencast

Advertisements

Create Task Questions

  1. The video of the program running, the written responses, and the program code (as a PDF).
  2. Describe any difficulties, describe the incremental and iterative development process, and describe whether it was collaborative or independent.
  3. Describe how each algorithm within the algorithm functions independently and how they aide in the function of the algorithm that uses them.
  4. Describe how the abstraction handled the complexity of the project.
  5. 1 min / 30MB
  6. PDF
  7. Citations could be in 2a or as comments in the code in 2e. Comments go in the code in part 2e.

Algorithm 2

algorithm2

The bubbleSort algorithm compares two numbers in an array and swaps them if the larger number is on the left. It repeats this until it doesn’t swap at all which would indicate that the  array is sorted in least to greatest order.

The swap algorithm takes in an array of values and two integers (each indicating a different address in the array) switches the two variables values and returns the array with the two values swapped.

The bubbleSort algorithm relies on the swap function in order to do its job properly. The whole concept of bubbleSort revolves around its ability to swap to values based on certain conditions. The swap function could theoretically have a use in any function but it was specially created for this one.

Abstraction

Link to Abstraction

This abstraction displays a menu to the user and returns their choice. Since the menu pops up after every hangman game is played, it is efficient to turn this into a function that can just simply be called. The phrase “get_choice” is much easier to understand than all of the print statements that would have to be put there if I chose not to make this a function.  The get_choice function was used in several places (like at the start of the program, after each game, etc.) so it was just easier to consolidate this into one function rather than a bunch of copy and pasted code.

Algorithm

algorithm

This algorithm is designed to take in a word from the user, check if that word is contained in a file, and if it isn’t contained in the file it will add it to it. (If it is in the file the word will be rejected). It accomplishes this task but accepting the input and then using if statements to run some tests on the word. It uses the pickle library to interact with the external file. First, the word is added to an array and then the word is sent to the file when the method is quit.