Courses‎ > ‎Software Development 2‎ > ‎Dyrland-Weaver‎ > ‎


All smaller assignments (those posted here) should be uploaded as submodules to the workshop repository in the appropriate assignment directory. Remember to use HTTPS to link your submodule.

Work 13: Create a nice text reduction to go with your meal

posted May 2, 2017, 9:31 AM by JonAlf Dyrland-Weaver

With your table buddy:
  • Pick a book from project gutenberg
  • Use map/filter/reduce to do the following:
    • Find the frequency of a single word
    • Find the total frequency of a group of words
    • Find the most frequently occurring word
Submit this in the workshop under map-reduce

Work 12: Decorating with style!

posted Apr 27, 2017, 6:23 AM by JonAlf Dyrland-Weaver   [ updated Apr 27, 2017, 11:32 AM ]

Python decorators are used when we want to apply the same process to multiple functions.
This can be useful for developing a logging framework to help developing and debugging code. Consider the following two kinds of logging:
  1. Printing out the name of a function and its arguments each time it runs.
  2. Printing out the amount of time a function takes to run.
In order to do this, you need to be able to do the following (in addition to creating closures and decorators)
  1. Get time information
    • python has a time module, after importing you can do the following:
      • time.time() will give you epoch time
  2. Pass arguments from a function variable (f) of an outer function (wrapper) to an inner function (inner)
    • *arg represents arguments passed to a function, look at the following:
      • def wrapper( f ):
           def inner( *arg ):
               return f( *arg )
           return inner

        closure = wrapper(foo)
        closure( -2, 3, 'hello' ) #will run foo with the arguments -2, 3, 'hello' through wrapper
  3. Get the name of a function
    • if f is a variable that represents a function f.func_name will return the name of the function.
  4. Before you go onto the rest of this assignment, please try these things out
Your mission is to create the structure for 2 decorators, one to log the name and arguments of a function and one to log the execution time.

What would this all look like?
  • If you had a standard recursive fibonacci function, putting a name and argument logger (by creating the appropriate closure apparatus and using it as a decorator) on it would result in output like the following:
    • $ python 
      fib: (2,)                                                                                                                                                  
      fib: (1,)                                                                                                                                                  
      fib: (3,)                                                                                                                                                  
      fib: (2,)                                                                                                                                                  
      fib: (4,)                                                                                                                                                  
      fib: (2,)                                                                                                                                                  
      fib: (1,)                                                                                                                                                  
      fib: (3,)                                                                                                                                                  
      fib: (5,)                                                                     
  • If you had a different function, and created an execution time logger, you might see output like this:
    • $ python
      execution time: 4.87653708458

Submit this in the workshop under decorators

Work 11: Set your pythons to list comprehension

posted Apr 20, 2017, 8:35 PM by JonAlf Dyrland-Weaver

Consider in python using lists to represent sets, as they are defined in math. If you do so, you can perform basic set operations using list comprehensions. 

Your mission, create list comprehension-based functions that perform the following set operations on python lists:
  • Union of the sets A and B, denoted A  B, is the set of all objects that are a member of A, or B, or both. The union of {1, 2, 3} and {2, 3, 4} is the set {1, 2, 3, 4} .
  • Intersection of the sets A and B, denoted A ∩ B, is the set of all objects that are members of both A and B. The intersection of {1, 2, 3} and{2, 3, 4} is the set {2, 3} .
  • Set difference of U and A, denoted U \ A, is the set of all members of U that are not members of A. The set difference {1, 2, 3} \ {2, 3, 4} is {1}, while, conversely, the set difference {2, 3, 4} \ {1, 2, 3} is {4} . When A is a subset of U, the set difference U \ A is also called the complementof A in U. In this case, if the choice of U is clear from the context, the notation Ac is sometimes used instead of U \ A, particularly if U is a universal set as in the study of Venn diagrams.
  • Symmetric difference of sets A and B, denoted A  B or A  B, is the set of all objects that are a member of exactly one of A and B (elements which are in one of the sets, but not in both). For instance, for the sets {1, 2, 3} and {2, 3, 4} , the symmetric difference set is {1, 4} . It is the set difference of the union and the intersection, (A  B) \ (A ∩ B) or (A \ B (B \ A).
  • Cartesian product of A and B, denoted A × B, is the set whose members are all possible ordered pairs (ab) where a is a member of A and b is a member of B. The cartesian product of {1, 2} and {red, white} is {(1, red), (1, white), (2, red), (2, white)}.
Taken from wikipedia
put this under sets in the workshop

Work 10: Comprehending passwords

posted Apr 20, 2017, 6:51 AM by JonAlf Dyrland-Weaver

With your table buddy:
  • YOUR TASK The First:
    • Write a function that uses list comprehension to return whether a password meets a minimum threshold: it contains a mixture of upper- and lowercase letters, and at least one number.
  • YOUR TASK The Second:
    • Write a function that uses list comprehension to return a password's strength rating. This function should return a low integer for a weak password and a higher integer for a stronger password. (Suggested scale: 1-10) 
    • Consider these criteria:
      •  mixture of upper- and lower-case
      • inclusion of numerals
      • inclusion of these non-alphanumeric chars: . ? ! & # , ; : - _ *
submit this under pwchkr in the workshop

Work 9: I'd kinda' like to be the president. So I could show you how your money's spent

posted Mar 17, 2017, 6:38 AM by JonAlf Dyrland-Weaver

It's federal budget season and we thought you might like to know something about where the money goes. 

Submit this in the workshop under d3

Work 8: Why won't anyone listen to me?

posted Mar 8, 2017, 7:49 AM by JonAlf Dyrland-Weaver   [ updated Mar 10, 2017, 10:12 AM ]

  • Create an html/js program with the following features
    • An svg container
    • 2 buttons, one labeled clear, the other labeled move
  • Enable the following event listeners for the svg area
    • Clicking on a blank section of the sag area should create a circle at that position
    • Clicking on a circle once should change its color, no new circles should be added to the svg container
    • Clicking on a circle a second time should remove the circle and add a new one to the svg container at a random location
      • Don't put this all in a single event listener
  • When the "move" button is clicked, the circles should start to move around the svg container, bouncing off the walls
    • The other event listeners should still function as described above.
    • NEW: When circles reach the middle of the svg container, a new circle should be added half the size of the original, going in the opposite direction of the original, and the original circle should decrease its size by half.
    • When circles have a radius < 1, they should be removed from the page.
submit this in the workshop under svg-interactive

Work 7: Vanimainiacs

posted Mar 2, 2017, 9:02 AM by JonAlf Dyrland-Weaver

Recreate the animations from work 5 using svg.

Submit this ins the svg-animation folder in the workshop.

Work 6: Connect the vector dots

posted Feb 28, 2017, 8:35 AM by JonAlf Dyrland-Weaver

Recreate your connect the dots html/javacsript program using SVG instead of the canvas.
  • Every time the user clicks inside the SVG area, a circle should be drawn.
  • After the first circle, every subsequent click should also result in a line from from the previous circle to the next.
  • Include a clear button
    • clearRect() will not work, that is a canvas method. You need to remove all the circles somehow...
Put this under svg in the workshop

Work 5: Animanics!

posted Feb 17, 2017, 7:04 AM by JonAlf Dyrland-Weaver

Create an html5/javascript program that can display the following animations:
Put this in the animation directory in the workshop.

If the name is unfamiliar to you, read this.

Work 4: Connect the dots

posted Feb 14, 2017, 6:44 AM by JonAlf Dyrland-Weaver

Create the page demonstrated in class today. You Should use the same html/javascript files that you had from yesterday.

  • Your javascript code should be able to to do, at a minimum 2 things
  • Draw a connected series of dots inside the canvas as the user clicks inside it.
  • Clear the canvas when the user clicks the clear button.

1-10 of 14