Lesson 5
Writing Reusable and Self-explanatory Programs
Chapter 11: Summary
Summary
Phew! Congratulations on completing this lesson. I am aware that this is probably one of the more intense lessons you will experience (along with Lesson 4). However, it is one of the most important lessons out of all the lessons of our course. It will go a long way preparing you to write larger, more complex programs in the future. Hopefully you have appreciated the power of writing self-explanatory and modular programs!
Now, as usual, let us recap and check whether you are able to answer the following questions. Make sure you are able to answer all of these before taking a well-deserved break!
- Do you know how to assign values to multiple variables in a single line in Python?
- Do you know how to swap variables? In the traditional way? And the Pythonic way?
- Do you know how augmented assignment operators in Python work?
- Do you know the operator precedence for augmented assignment operators in Python?
- Do you know what a function is?
- Are you able to define your own custom functions?
- What is the difference between a parameter and an argument?
- Do you know how to return an object from a function?
- Are you able to call a function?
- Do you know what code refactoring means, and are you able to refactor your code?
- Do you appreciate both the bottom-up and top-down approach to structuring code? And are you aware that you can use both styles together?
- Do you understand what we mean by modular code?
- Do you understand what we mean by highly abstracted code?
- What are positional arguments?
- What are default arguments?
- What are keyword arguments? How do they relate to default arguments?
- In a function call, are you allowed to pass keyword arguments before positional arguments?
- Do you know how to return multiple objects from a function in Python?
- What is a local scope?
- What is a global scope?
- What is a stack frame?
- What is a stack trace or stack traceback?
- Do you know how to write docstrings?
- What does the assert statement do in Python?
- Are you able to write automated test codes?
You have also looked at the concept of git branches. Here are the commands that might be useful: git branch
, git checkout
, git merge
.
You have also spent quite a lot of time refactoring your robot project (phew!) Hopefully all that hard work will pay off in the future when you expand your robot project. And hopefully, you have learnt how to structure your code in a modular and self-explanatory fashion through this exercise.
The next lessons will hopefully not be as mentally draining as the past two lessons. I will continue giving you more tools to write more efficient and readable code. I have already given you a hint on what to expect next - you will be looking at how to represent and manipulate a list of objects.
Ok, it is time to take a break, stretch your body and relax your brain! If you are doing this lesson in Week 1, take at least 30 minutes break. Otherwise, you can take at least a day. See you in the next lesson!