Putting It All Together
Taking the five rules, we have the following Game of Code:
You read data as input to your program (Rule #5)
You store this data in storage (variables) (Rule #4)
You use these variables to perform tests… (Rule #3)
… so you can JUMP around… (Rule #2)
… the sequence of instructions… (Rule #1)
… transforming the data into new variables (Rule #4)…
… which you then write to output for storage or display (Rule #5)
While this seems simple, these little rules create very complicated software. Video games are a great example of very complicated software that does this. A video game reads your controller or keyboard as input, updates variables that control the models in the scene, and uses advanced instructions that render the scene to your screen as output.
Take the time now to go back through exercises you’ve completed and see if you understand them better. Does using dis() on code you didn’t understand help, or is it more confusing? If it helps, then try it on everything to get new insights. If it doesn’t help, then just remember it for later. This will be especially interesting when you do it to Exercise 26.
The List of Byte Codes
As you continue with the exercises, I’ll have you run dis() on some code to analyze what it’s doing. You’ll need the full list of Python byte codes to study, which can be found at the end of the dis() documentation.
dis() Is a Side Quest
Later exercises will have short sections that ask you to run dis() on the code to study the byte codes. These sections are “side quests” in your education. That means they are not essential for understanding Python, but if you complete them, it may help you later. If they’re too hard, then skip them and continue on with the rest of the course.
The most important thing about dis() is that it gives you direct access to what Python thinks your code does. That can help you if you’re confused about how your code works or if you’re just curious about what Python is actually doing.