In earlier Years, we discussed how we should think of the problem from the point of view of the "objects" that make sense to a human describing the problem
In our example so far, we have:
• Wizard
• House
• Wand
An object that belongs to these classes has _attributes_
/2
You've already come across the two types of attributes an object can have
• Data attributes are variables that are connected to the instance of the class. They are also called instance variables
• Methods are functions connected to the instance of the class
/3
Slightly off-topic from my usual on this account—but a lot of my work is also linked to children's education (coding primarily, but let's think beyond subjects)
I've taken a stab at what "homework" in the near-future could look like, using a GPT-first, cheat-proof approach…
/1
It solves reasonably well the problem of "cheating" by incorporating GPT into the process and requiring the whole conversation to be submitted, including first drafts, suggestions by GPT, second drafts, and so on
Teachers can craft the right prompts that all students use
/2
But main point is not that it's cheat-proof but that it leverages the opportunities LLMs provide to improve learning
I collated some ideas & examples of how learning (children, but also adult-learning) could change soon
What Python data type would [a multi-storey car park] be?
–––
You drive into a multi-storey car park, find a spot to park, and then you ask yourself: "what data structure would best represent this car park", of course
Let's explore
1/
Let's name the object `car_park` and it contains several levels. I'll also look at `level` which represents one the levels. This will be a different data type
The car park has a fixed number of levels which don't change. Therefore, `car_park` is immutable
2/
You can count the levels – `len(car_park)` exists
You can determine whether `level` is in `car_park`, so `car_park` is a container
You can go through the levels one after the other, so `car_park` is iterable
These three properties make `car_park` a collection, too
3/
It depends whether we want to prioritise the use case when the tables are being used during normal service, with diners sitting on them and waiters taking their orders and bringing them food [dictionary is a good choice]…
/2
…or if you want to prioritise the setting up process before the restaurant opens its doors when staff go from one table to the next to clean it and set it up. For this, you could be tempted to use a sequence instead, such as a tuple or list
/3