This is an archived version of the course. Please find the latest version of the course on the main webpage.

Chapter 9: Summary

Summary

face Josiah Wang

Phew! We have covered a lot of different topics in this lesson! Hope you are not too worn out!

Can you recall what we have covered in this lesson? Try to recall as much as you can on your own before continuing with my list.

The first main topic we covered relates to objects. Are you able to answer the following questions? If not, make sure you know the answers before you call it a day!

  • What is an object identity?
  • What function can you use to find out an object’s identity in Python?
  • Do you know what the two identity operators (is and is not) do?
  • How is x is y different from x == y?
  • How is the is operator mostly used?
  • Do you understand what object methods are?
  • How are methods similar/different to functions?
  • Can you recall some useful str and list methods?

The second main topic we discussed is related to the built-in dictionary (dict) data type. Try answering the following questions.

  • What are Python dictionaries?
  • What are dictionary keys?
  • What are dictionary values?
  • How do you initialise a dictionary?
  • What can/cannot be used as Python dictionary keys?
  • Do you know how to retrieve a value from a dictionary, given a key?
  • Do you know how to modify a value in a dictionary, given a key?
  • What happens when you try to retrieve/modify a value in a dictionary when a key does not exist?
  • How would you ensure that Python will not give you any error if you try to retrieve/modify values with a non-existing key?
  • Are you comfortable accessing values in nested dictionaries, or when the values are compound types like lists, tuples or dict?
  • Are you familiar with the .keys(), .values(), .items() methods of dict?
  • What other dict methods can you think of?
  • Can you recall some possible use cases for dict?
  • How would you use dict to model an object?

Our third main topic was about recursion. More questions for you to ponder!

  • What are recursive functions?
  • What are the two kinds of cases that you have to consider for recursive functions?
  • How are recursive functions related to loops?
  • Can you recall some use cases for recursive functions?

The fourth main topic was on handling exceptions.

  • What are exceptions?
  • How do you handle exceptions?
  • What is a try clause?
  • What is an except clause?
  • How to you catch specific exceptions?
  • How to you catch multiple specific exceptions?
  • Can you catch non-specific exceptions? How?
  • Do you understand why PEP 8 recommends that you keep your try blocks small?
  • What does the else clause do when used with a try clause?
  • What does the finally clause do?

You have also refactored your robot project to use dict to represent your robot. This makes your code easier to read, as you can treat of your robot as a single entity with some attributes. This will come in handy as we dive deeper into the concept of objects and object-oriented programming in future lessons.

You have also learnt how to git clone a remote repository. You also learnt how to keep your local repository up-to-date and synchronised with the remote repository - e.g. with git pull and/or git fetch + git merge.

Now that was a long list! 😲

In the next lesson, we will start moving into a more object-oriented style of coding, and you will also pick up even more tools for your programming toolbox!

Take a well deserved break, and I look forward to seeing you learn more in the next lesson!