Tuesday, July 8, 2008

First Python Fun Tutorial - IDLE

Getting Python -
Welcome to my site! In this tutorial we will be getting up and running with python. These tutorials are not meant to be long and drawn out, just fun and fast! So the first step is to download and install python from http://www.python.org/. Then open up idle, you should have text that says something like this...




Warming up to IDLE
This is the python command prompt. You can do alot of things from here. For example try putting in 7 + 7 press enter and you will get 14. Some of the common Python operators are:

1. Addition: +

2. Subtraction: -

3. Division: /

4. Multiplication: *

5. Exponent: **

You should now see what python can do as a basic calculator. But what about variables? That is something that a normal calculator can't do, Put in this: (Don't type the >>>)

>>> x =5

>>> y = 23

>>> x*y

In python variables are automatically assigned a type based off what you set them equal to. A variable can be any name you like.(As long as it has no spaces or numbers) Try some of these:

>>> apples = 13

>>> price = 0.50

>>> price * apples

Python can also handles strings as variables. (Strings is just a fancy name for words) Like:

>>> moto = "I love pythonfun.blogspot.com!"

>>> print moto

That's it for this tutorial. I know that it is not the most exciting, just syntax stuff. Next tutorial though we are going to start making some useful programs! Happy Coding!

No comments: