[Week 2] Programming
on your own terms
In the lecture we discussed the next assignment — Holy Wars. The concept of it sounds pretty interesting so I’m keen to listen to the discussion of the topics. The topic assigned to me is about the length of variable name, after swapping with Penny.
One of the main things I learnt from the lecture was the different key shortcuts. While I already knew a few, some I didn’t even knew existed so it will be fun to test them out. This is a list of the new ones I learnt for future reference:
alt + f3 = select all that match
shift + alt + down/up = extend cursor Lab:
This week was yet again enjoyable and nothing too strenuous. Exercise 1 and 2 were pretty quick after finally getting the linter/flake 8 program to work since it was a lot more effective for visualising the issues compared to manually through terminal prompts. One problem I needed help for was the docstring warning which I still don’t really understand.
Exercise 3 was the hardest yet best of the three. Finally being able to make our own code to solve problems! While working through them at the beginning the hardest part was syntax since I had no clue how python works (probably should have done the tutorials on the homework prior to this..). Because of this I started by doing the sections in pseudo code or in C. After this I was looked at the previous exercises and well as use google to help figure out how to translate to python.
The mapping one I found to be a bit more difficult since I wasn’t sure how mapping works. Because of this I had to do a bit more research and watched Ben’s video on the section. From this the basic structure of a map is shown to be: map(function_to_apply, list_of_inputs). I will need to use it a bit more to get the hang of it though.
The loop exercises were easy after figuring out the first two since the remaining were the same basic structure as these with minor alterations. loop 7 required a bit more thinking than the rest. However after drawing diagrams and thinking about the process clearly, it wasn’t too bad to come up with a solution. There probably is a cleaner approach compared to the one I used but for now this should be alright.
The first reading was just a command line crash course. Most of which I already knew but some I had forgotten, so it was good to refresh the memory. The one about abstraction made the idea of a simple car simulation go from 0–100 real quick.
I started Code Academy, it went through the basics of python so it was pretty helpful to train in python as well as learn a few new things along the way.