Theater¶
An exciting warmup activity is to have a short theater play about programming.
Below you find the script for a 5’ play.
print 3 copies of the script (
DataTypesHaveDinner.pdf)give them 5’ to prepare themeselves
make room on the stage and get out of the way
The play fits best to start a lesson after the students have heard about the three data types.
Data Types have Dinner¶
Task: act out the dinner by reading from the script.
Characters¶
• String
• List
• Dict
Action¶
List preparing dinner. String comes home.
S: Hi List!
L: Hi String!
S: (agitated) You know what? I had a terrible day at work!
L: What happened?
S: I had Unicode issues all day long. I have been telling my users they should use proper Unicode characters ever since Python 3.0. And still they get the encoding wrong.
L: Is the encoding really that important? I wouldn’t care too much.
S: Yes I know, “everything is an object”. You keep iterating that.
L: OK I admit I am not looking too closely at my contents like you do. But dict is doing the same.
S: Oh, there they are.
Dict comes in
D: Hi folks! You know what! I had a terrible day at work!
S+L: What happened?
D: The same user came back again and again. It was get values, get values all day long.
S: What’s so bad about that? Nobody can look up things as quickly as you do.
D: Yes, but if you want my values in a certain order, you end up checking all of them. This is really a lot of work.
L: Send them to me next time. I can keep my stuff sorted.
D: (slightly annoyed)
S: So how was your day, List?
L: Terrible day as well? Imagine, someone wanted to index me with a string!
D: (grinning)
S: No way. That’s embarrassing! I hope you gave them a an IndexError.
L: A big one! Just to make sure they use an integer index next time.
D: (still grinning and nodding)
L: And what are you grinning about?
D: I don’t see why you can’t put a string in your square brackets. Strings work fine as keys with me.
L: Really? Hey String, how would you feel being one of their keys?
S: I don’t mind as long as I’m unique.
(List and String do a high-five)
(doorbell rings)
S: Hey it’s a delivery! We got new data.
D: Who is it for?
S: I’m immutable, so it has to be one of you.
L: I could just append it to myself.
D: Check if there’s a key.
S: Yes, there is one. Here you go.
D: And now let’s eat.