Skip to main content

Foundations of Python Programming: Functions First

Section 1.8 Predict Before You Run!

You’ve run your first program! You’ll be doing that a lot in this book and the programs will become increasingly complicated. One way to help understand what is happening and learn programming is predicting the effect of running a snippet of code before actually running the program. Later on in your development, you may make predictions about large snippets of code, but for now you will typically be predicting the effect of executing a single line of code. A prediction will either be about what gets printed out, or about the value of a variable, or that an error will occur.
A prediction is not a random guess. It is based on some explanation you have about what the current state of variables is and about what you think certain commands in Python do.
You have attempted of activities on this page.