Chapter 1: Introduction

Recap

face Josiah Wang

Welcome back!

Now, let us recap what you have learnt to date.

Remember that we started off from the very beginning. You learnt all the basics of programming, and hopefully remember to always understand and think about the problem first before starting to code! You also learnt how to write reusable and highly abstracted code via functions.

You also explored more complicated data structures provided by Python: lists, range, tuples, str, dict, and in the previous lesson, sets.

Set operations

We then started moving towards a more object-oriented style of programming. You wrote your own custom classes with attributes and methods. You have used constructors (__init__()) to initialise attribute values etc. Python also offers magic methods that you can implement to do special things with your custom classes. Hopefully you have started appreciating the power of object-oriented style of structuring programs!

Class diagram for car

We also discussed what Python modules actually are, and how you can structure your scripts easily by dividing them into modules.

You also looked at how to read and write to files.

You were also introduced to two possible paradigms for validating your inputs - Look Before You Leap (LBYL) and Easier to Ask for Forgiveness than for Permission (EAFP). Python recommends the EAFP approach.

You refactored your robot project yet again, this time making it more object-oriented by converting the dict representation into a custom Robot class with attributes. You later also added some methods to represent your robot’s actions.

We also wrapped up our tutorials on Git, by putting your robot project on a remote repository, and git push any local commits to the remote repository. Hopefully this will be enough of an introduction for you to further explore the world of Git !