Exercise 1: How is the weather?

Statistics is about using data to inform decisions.

Data  →  Decisions

You do this all the time already, so there is nothing amazing happening.

Looks like rain

Lets say you're about to leave your home for some morning chores. Upon opening the front door you notice that it's raining. You'd likely consider retrieving a rain coat before heading outside.

Seeing Rain (is the data)  →  Wearing raincoat (is your decision)

Even as kids, most of us regularly make decisions like this.

Your first program

To ease you into thinking statistically, you will type simple commands.

In the Editor, create a new file if you didn't already done so in the previous exercise. You will see a blank editor area and a blank Python area.

macemptyeditor

You will type stuff into the top section and, later, that stuff will cause other things to be displayed in the bottom section.

When I write 'type the code', or 'create a new file', this is the window to which I'm referring, specifically the top section.

Write the following code in the editor. Do not copy and paste for this or any future exercise in this book. Type each and every character exactly as typed below.

printinginput

Then save what you wrote by clicking File | Save As...

Name this file exercise1.py. While it doesn't matter where you save the file, I put mine in a new folder called "Learning Stats". You should, too.

Then click Run | Run Module. On Windows this looks like:

Windowsrunmoduleprinting

On Mac, the Run | Run Module menu looks like this:

Macrunmoduleprinting

What you should see

Upon clicking "Run Module", Python will respond with the following if you typed it correctly. (Look at the bottom section, below where it says Python.)

printingoutput

If you didn't get the same thing I did, then carefully go through the code line-by-line. One incorrect symbol can cause things to run improperly, if at all.

Note

Notice that single (') or double (") quotes can be used. You just have to be consistent within each line of code. When in doubt, use double quotes.

Creative Commons License
Learn Stats in 10,000 Hours by Jonathan B. Miller is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
comments powered by Disqus