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

Chapter 10: Summary

Summary

face Josiah Wang

And we have finally reached the end of the lesson. Phew!

Let’s recap!

The main topic of this lesson is to have you understand how objects can interact with each other in object-oriented style programs. Try answering the following questions.

  • What do we mean by dependency between two classes?
  • What are the different ways in which a class can use another object?
  • What is aggregation/composition? How can you achieve this in your classes?

I have also provided you more practical experience by asking you to refactor your robot project. You have created a RobotFactory class that creates new Robots. Later on in the lesson, you further introduced more new classes and started making your robot project even more object-oriented with rich interactions between the different classes.

We also looked at various different Python-specific topics. Are you able to answer all the questions below?

  • Do you know how to use the enumerate object?
  • Do you know how to use the zip object?
  • What is list comprehension and how do you use it?
  • How do you use set comprehensions?
  • How do you do dictionary comprehension?
  • How is a generator expression different from list comprehension?
  • What is JSON?
  • How do you load a JSON file into a Python data structure?
  • How do you load a JSON string into a Python data structure?
  • How do you save a Python data structure into a JSON file?
  • How do you convert a Python data structure into a JSON string?
  • How would you read in command line arguments?
  • What is a Python package? Why is it useful?
  • How do you organise a package?
  • Do you know how to import a package?
  • How do you run a Python module in a package from the command line?
  • What is the difference between a namespace package and a regular package?
  • What does the __init__.py file do?
  • Do you know that Python Exceptions are essentially class instances?
  • How do you provide custom arguments to a Python Exception?
  • How do you obtain the arguments of a Python Exception?
  • How do you raise an Exception instance?

That was actually more covered than I initially thought! I hope that at least some of it was inspiring or helpful to you!

The next lesson is the final lesson in our Core series. We will try to make object-oriented programming even more powerful and discuss the concept of inheritance. We will also explore more Python-specific features to help make your programming life more colourful!

See you in the next lesson!