Python
I personally thing that Python is a nice language to start learning to program. The language is clearer as is the structure and it is quite simple to run it on your computer as work is run through an interpreter program rather than being compiled (converted from a Python program to a PC program) first.
You can download everything you need from (here) . Click the link, click "Download" and (I suggest that you) download 2.7.3 for your operating system. I downloaded the Python 2.7.3 Windows Installer.
Run the downloaded file to install it. You can now run Python from the command line (don't worry about that for now) or just as you would any other application (Start or Start Orb on Windows - Programs - Python). You'll first see the Python Shell. This is the application window where your Python code will be run. You can test commands in here too. Try typing these lines (press enter after each line):
text="Hello World"
print text
With Pyhon there's no need for numbers or punctuation to finish a line. You should see a line display:
Hello World
That wasn't too bad was it? Well, there's a lot more to learn and play with. If / when you feel you'll like to write a longer program and save it, click "File" and then "New". This opens up a Python editor called IDLE. Type in our little program from above. You'll notice that it doesn't automatically run the code you type. Now, press F5. It'll ask you if you want to save your work (you'll have to if you want to run it). The save dialogue should display the directory where Python is installed. Just create a new folder in there for your work, give your work a name, select to save it as a .py file and save it. You should now see it run in the original Python Shell window.
You can go back and edit or add to your work by selecting the IDLE window. Try changing the name (we called it text) to something else. You can use almost anything for a name but it has to start with a lower case letter and can't be a reserved word (an existing Python command). Whatever you change it to, make sure you change it on the second line too, like this:
example="Hello World"
print example
It will give the same result. example now carries the string (text) "Hello World". Remember, it's F5 to save and run the code.
Try this:
name=raw_input("What is your name?")
print "hello "+name
Ok, don't panic here! raw_input means it will take information from the user. The first line states that it will store that information in the name of name.
Notice the punctuation used. The brackets hold what will be displayed on the screen before the request for information is made. We've put: What is your name? in quotes because we're telling Python to display exactly what we typed. What do you think would happen if we added this to our previous code and, instead of using the quotes, we used (example). It would 'ask' Hello World! Basically, Python needs to know exactly what we're asking it to do. By using quotes, we're making it clear that we're not referring to information stored elsewhere, we're simply asking it to display something.
Now, we've done something different with the print command on line 2. Again, we've used quotes because we want to display something exactly as it is typed. By using the + symbol, we've told python that we want to add something to the end. That something is name. What name is depends on the result of the first line.
I'll finish this introduction with some information about comments. You can add comments to your code to help yourself and others understand what's going on. Of course, you have to make it clear to Python that a comment is just that and is not to be interpreted as code. There are two ways of doing this. There's the single line comment which is made by adding a hash (or pound) to the beginning of a line:
#this is a comment and will not be interpreted by Python.
and there's the multi line comment which is made by placing three quotation marks at the start and at the end of a comment:
"""This is a multi-line comment.
It will not be interpreted by Python.
Don't forget to close it off. """
This code will still run fine:
name=raw_input("What is your name?") #Asks for the user's name and saves it as name
print "hello "+name #Prints hello followed by name.
Once you've saved your work, you can close any open Python windows. Now, you can browse through you computer to find the file(s) you have created. If you double click them they will run via Python in the command prompt. When you run your code like this it will run much quicker.
Well, I probably won't go on to explain every command that Python has to offer as there are already plenty of websites out there that do a far better job than I could. What I will do is show you some of the stuff I've done so far and share the fun. Feel free to tinker with my code and even share your progress back with me via my Contacts page.
You can download everything you need from (here) . Click the link, click "Download" and (I suggest that you) download 2.7.3 for your operating system. I downloaded the Python 2.7.3 Windows Installer.
Run the downloaded file to install it. You can now run Python from the command line (don't worry about that for now) or just as you would any other application (Start or Start Orb on Windows - Programs - Python). You'll first see the Python Shell. This is the application window where your Python code will be run. You can test commands in here too. Try typing these lines (press enter after each line):
text="Hello World"
print text
With Pyhon there's no need for numbers or punctuation to finish a line. You should see a line display:
Hello World
That wasn't too bad was it? Well, there's a lot more to learn and play with. If / when you feel you'll like to write a longer program and save it, click "File" and then "New". This opens up a Python editor called IDLE. Type in our little program from above. You'll notice that it doesn't automatically run the code you type. Now, press F5. It'll ask you if you want to save your work (you'll have to if you want to run it). The save dialogue should display the directory where Python is installed. Just create a new folder in there for your work, give your work a name, select to save it as a .py file and save it. You should now see it run in the original Python Shell window.
You can go back and edit or add to your work by selecting the IDLE window. Try changing the name (we called it text) to something else. You can use almost anything for a name but it has to start with a lower case letter and can't be a reserved word (an existing Python command). Whatever you change it to, make sure you change it on the second line too, like this:
example="Hello World"
print example
It will give the same result. example now carries the string (text) "Hello World". Remember, it's F5 to save and run the code.
Try this:
name=raw_input("What is your name?")
print "hello "+name
Ok, don't panic here! raw_input means it will take information from the user. The first line states that it will store that information in the name of name.
Notice the punctuation used. The brackets hold what will be displayed on the screen before the request for information is made. We've put: What is your name? in quotes because we're telling Python to display exactly what we typed. What do you think would happen if we added this to our previous code and, instead of using the quotes, we used (example). It would 'ask' Hello World! Basically, Python needs to know exactly what we're asking it to do. By using quotes, we're making it clear that we're not referring to information stored elsewhere, we're simply asking it to display something.
Now, we've done something different with the print command on line 2. Again, we've used quotes because we want to display something exactly as it is typed. By using the + symbol, we've told python that we want to add something to the end. That something is name. What name is depends on the result of the first line.
I'll finish this introduction with some information about comments. You can add comments to your code to help yourself and others understand what's going on. Of course, you have to make it clear to Python that a comment is just that and is not to be interpreted as code. There are two ways of doing this. There's the single line comment which is made by adding a hash (or pound) to the beginning of a line:
#this is a comment and will not be interpreted by Python.
and there's the multi line comment which is made by placing three quotation marks at the start and at the end of a comment:
"""This is a multi-line comment.
It will not be interpreted by Python.
Don't forget to close it off. """
This code will still run fine:
name=raw_input("What is your name?") #Asks for the user's name and saves it as name
print "hello "+name #Prints hello followed by name.
Once you've saved your work, you can close any open Python windows. Now, you can browse through you computer to find the file(s) you have created. If you double click them they will run via Python in the command prompt. When you run your code like this it will run much quicker.
Well, I probably won't go on to explain every command that Python has to offer as there are already plenty of websites out there that do a far better job than I could. What I will do is show you some of the stuff I've done so far and share the fun. Feel free to tinker with my code and even share your progress back with me via my Contacts page.