Hands-on team activity for assigning features and use cases to different data structures.
| Parameters: | |
|---|---|
| Duration: | 25 minutes |
| Participants: | 6–30 students |
| Instructors: | 1–X teachers (ideally 1 per 6-8 participants) |
| Class: | table for each group |
| Resources: | printed activity cards |
| Prerequisites: | have seen the data structures |
- Know different data structures in Python (list, tuple, set, dictionary) and their properties.
- Justify selection of the appropriate data structure for selected use cases.
- Print the set of paper cards for each group.
- Use one-sided printing.
- If possible, print on paper of 3 different colors: names and examples of the data structures on the first, features on the second, and use cases on the third. This will help both you and the students.
- Cut the pages into individual cards.
- Print an answer table for each instructor.
- Let people divide into groups of 3–4 people each as they see fit.
- Give each group the cards with data structures and their features (first three pages).
- Task for the group: Assign given features to the data structures. If a feature applies to multiple data structures, you have it multiple times.
- After the group reads the features, make sure they understand all of them (especially those like mutability).
- When a group is finished, give them the cards with real-world use cases (the last, fourth page).
- Task for the group: Choose the appropriate data structures for the given use cases and justify your selection.
- When two groups are finished, have pairs of the groups compare their selection of data structures for the given use cases. Let them justify their choice to the other group.
- If there are enough instructors, keep one instructor with each pair of groups.
- When relevant or asked for, offer your own opinion or extra information.
- (Optional) When a group is finished but others are still working, have them think of other use cases when they would use the data structures.
- The students might not understand what a use case is. Explain what exactly you want from them.
- (Optional) When a group is finished but others are still working, have them experimentally measure the timing of basic operations in various data structures. This prevents the faster groups from being idle.
- Create a list and a set with a thousand, a million, or a billion elements by gradually appending numbers in a for loop starting from 1.
- Create large lists and tuples using the
rangefunction. - Insert elements into list and set.
- Lookup elements in the list, tuple, and set.
- When everyone is finished, invite the whole class to ask further questions or give feedback on what they learned.
- Preferably, continue with a programming exercise that practices data structures.
- Once the groups form, work with them individually if there are enough instructors (there is no need to have them perfectly synchronized).
- The groups should use the table (as opposed to laying cards on the floor) and have enough space on it. The full matching takes quite a lot of space (and working on the floor for long tends to become uncomfortable).
- Before giving a new set of cards to a group, check their matching according to the answer table. If there is enough time, have them correct their own mistake instead of pointing it out straight away.
- Group size is up to your choice, but 3–4 people turned out best (enough for discussion but still keeping everyone engaged).
- The activity will progress faster with skilled participants and slower with less skilled ones.
- Official documentation for Python data structures.
This activity ripped off was inspired by Martin Ukrop's Encryption modes and was written down by Valdemar Švábenský in 2018.