Each student receives cards with names of data types and cards with expressions. The goal is to assign the expressions to their corresponding data types.
| Parameters: | |
|---|---|
| Duration: | 10 minutes |
| Participants: | 1–20 students |
| Instructors: | 1 teacher |
| Class: | tables, pens |
| Resources: | printed cards |
| Prerequisites: | evaluating simple expressions |
- Realize the existence of the data type system in Python, which is implicit.
- Understand the difference between type and a concrete value/expression.
- Be able to determine the type of a given expression.
- Print the cards for each student.
- The PDF contains one page with cards for 2 students.
- Use one-sided printing.
- Cut the cards so that each student has 3 data type cards and 15 expression cards.
- Prepare a separate set of cards for each student and pin each set together by a paperclip. This will avoid the hassle with distribution.
- The motivation for this activity is that data types in Python are often overlooked.
- Hand out the card set to all students and ask them to assign the expressions to the appropriate types. The students must not use a Python interpreter, only pen and paper.
- When two neighboring students are finished, ask them to compare their solutions and discuss any differences.
- Allow time for questions.
- If a student is stuck, ask him/her to evaluate the expression to a single value.
- A quick check is that there should be 5 expressions in each of the 3 categories.
- A brief follow-up activity can be to let the students think about as many operations as possible for the given data types, and then comparing the results with a neighbor.
- If you don't have time to cut the paper into cards, have the students write in the paper directly.
Actually, we'd appreciate a good reference to a material that explains data types in Python really well. Please, e-mail it to valdemar@mail.muni.cz.
Valdemar Švábenský, 2017