Python for Parents - Part 1: Hello World!

image.png

Hello World!

Do you want to learn how to write computer programs?
Do you want to learn in Python?
Of course you do!

My son just started high school this year (that's UK high school, he's 11) and next year he'll be learning how to write computer programs. Now it may be remiss of me, being a programmer by trade, to have not taught him how to do this yet. When he starts lessons next year I expect him to be able to ask for the end of year assessment project and bash it out on day one. The family honour is at stake!

01101101 01111001 01110011 01100101 01100011 01110010 01100101 01110100 01101101 01100101 01110011 01110011 01100001 01100111 01100101

For parents?

Well, I'm assuming most kids learning Python aren't old enough to have a Steemit account (legally) but I'm writing this to 2 groups of people. Parents who want to learn how to code and parents who want to help their kids with their homework. Of course there's no reason you can't just show this to your kids (there's nothing unsavory!) or just read them for fun.

01110111 01101000 01101111 01100011 01100001 01101110 01110010 01100101 01100001 01100100 01110100 01101000 01101001 01110011 00111111

What is Python?

For starters, it's friendly. It's nothing like the low-level assembly or old BASIC languages, it almost reads like plain English. It's a high-level interpreted language named after Monty Python's Flying Circus (yes, really!).

High-level means you can do a whole lot in very few lines.
Interpreted means you don't have to wait for it to compile into a program, you just run the code.

00110001 01010011 01000010 01000100 01110100 01101111 01110100 01101000 01100101 01100110 01101001 01110010 01110011 01110100

So let's get coding!

Whoa there cowboy! The first thing you need to do is INSTALL Python. Your PC doesn't know how to process it yet. But don't worry, it's REALLY easy...

  1. Go here - https://www.python.org/downloads/
  2. Download the correct file for your operating system (get the newer of the 2 versions - currently 3.6.4). It's around 30Mb
  3. Run the file - accept all the defaults, there's no hidden malware or anything
  4. When you get to the end it will give you the option to allow longer names, I figure it can't hurt so I said yes - your mileage may vary.
  5. That's it, you're done. (Note: You may have to restart your PC)

To test this load up your command prompt (Windows key+R or Start->run then type "cmd" and hit enter) then type:

python -V

(note the capital "V") and hit enter.

01110000 01100101 01110010 01110011 01101111 01101110 01110100 01101111 01100011 01101111 01101101 01101101 01100101 01101110 01110100

Your first script

Now, you have 2 options. You can either navigate in the command window to a directory of your choosing - using a combination of...

cd ..

to go up 1 level,

cd [Directory name]

to go into a directory and

dir

to list the files and folders in the current working directory.

If that sounds too complicated, for now we can just create the script in whatever directory the command prompt puts you in! For me that's C:\Users\Stewart\ (yes, my name is Stewart... Hi!).

So, open up a text editor (no, not Microsoft Word!). If you don't know what a text editor is then keep it simple and open up notepad (it comes with windows). Other alternatives I approve of are Notepad++, Sublime and vi (if you're on Linux or just sadistic :P).

Before you even write any code go ahead and save the empty file as "test.py". Whenever you make a Python file, save it with the ending .py. Now we can start!

01110011 01100001 01111001 01101001 01101110 01100111 01001001 00100111 01101101 01100001 01110011 01101110 01100001 01101011 01100101

Your first command

The first command should ALWAYS be sending text to the screen. It's something of a programming tradition and the text you are REQUIRED (not really) to send is "Hello World!". So how do we do that?

print('Hello World!')

Wasn't that easy? Now, save the file and go back to the command window where you can now type:

test.py

and hit enter. You should see something like this...

C:\Users\Stewart>test.py
Hello World

C:\Users\Stewart>

If you do, congrats, you just wrote your first Python program! I promise the next one will be a little more impressive but baby steps... we'll get there!

If it doesn't look like that - put your result in a comment below and I'll try to help you.


Please tell me what you think of this so far. I know this first post is a little hastily written but as we get into more and more code things should become clearer.
Sort:  

So does the 011010001 mean something secretttttt???? :)

I thought they made cool separators, if you want to try to translate it then feel free :)

Hahahaha trickster!!! I was hoping it was a cool code for "the winning lottery number tonight is....."

😝

Well every line is different, and every line is broken into blocks of 8 "bits"...

I'm saying no more :P

Thank you.... Because I only read the first 6 words and then my brain shut off because I don't compute techie smart words.

When i see them, I are stoopid.

😂😂😂😂😂

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by Stormriderstudio from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.