Monday, 10 November 2014

Test 2 Thoughts

I thought the test went well. It was similar to the assignment. I definitely  thought it was easier than the first test. The assignment was excellent preparation for the test and I'm hoping the third assignment will become good preparation for the final exam.  I had the most trouble with the second question. You had to define the d = _____ ( something) and when I left the exam I remembered what I should have put!


def order(L):
        """ (list of numbers) -> None
Order L from smallest to largest. L is changed in-place. """ i=1
while i < len(L): j=i
while j > 0 and L[j] < L[j-1]:
L[j], L[j-1] = L[j-1], L[j] # swap L[j] and L[j-1] j=j-1

i=i+1


This question was done in tutorial. This took me a while to understand and figure out. I finally truly understood how to do it after the TA Christine did it on the board. The easiest way of thinking about figuring out how many steps there are is to think tally each step on the side of the code.

No comments:

Post a Comment