Title: Lesson 6: Classes and objects
Course: Basic scripting and programming > Section: Course Content

In the previous lessons we have already seen a bit of the object-orientation of Python. In this lesson we will take a closer look at classes and objects in Python.

Objectives:

- Get familiar with Classes and Objects in Python

Entrance requirements:

- Lessons 1-5

Required materials:

- Computer with Python
- The course book “Think Python” chapters 15, 16, 17 and optionally 18

learning outcomes:

At the end of the lesson the student:

- knows about user-defined types
- understands how rectangles can be represented as objects
- knows that objects can be created and returned by functions
- knows that objects can be changed and copied
- knows that an object can have data attributes and function attributes
- knows about the constructor function __init__()
- knows how to represent an object as a string using the __str__() method
- is able to apply all of the above

Learning activities:

- Read chapter 15 and 16 of the course book “Think Python”
- Read sections 17.1 to 17.7 of the course book
- As an extra challenge you can do the rest of chapter 17, and chapter 18

Tasks:

- Exercise 16.2
- Use the standard python modules datetime and time to nicely print the current date and time.
- Optionally: exercises of chapter 18

SUBMIT all your answers in a PDF document!

Planned time frame for this lesson:

6 hours