Very nice tut Beeg, couldn't have explained it better myself. Perhaps if I get some free time I'll write up some more advanced ones once they read this one. Write some more on functions and get into classes, but over all very nice job
The one function that I think needs pointing out is the len() function which I often find very usefull. If you need to find out how many items are in a list or dictionary just use len().
For example:
list = ["cat","dog",5,"bird"] # Creats a list with those objects in it
x = len(list) # assigns the function len to x
print x # prints out how many objects are in list, which is 4
I've used that little function many of a time for many differnt task.
len() also coutns how many characters in a string
For Example:
x = "Python rocks!"
c = len(x)
print c
would result in the interger 13 being printed.
The last thing I would like to point out is all those example above we're made using IDLE. Python can be just as powerful and you can code often times quicker with just using the command based version, regular old Python.exe.
for exmaple if I wanted to know how many charcters were in plan text document quickly, I'd just go to run and fire up python.exe.
Once in I could quickly type
file = open("C:/file.txt",r) #open a file for reading
x = file.read() #assign files contents to x
file.close() #close the file
len(x) #count characters in file and that will automaticly print out the contents, where as if I used IDLE, I would have to go in, save it first and then run it.
There isn't that big of a differnce in time, if you need to do something small, and you need it done fast, I'd use the command line, if you're going to be writing a script with a bunch of functions and classes and possibly writing differnt modules, then by all means it's best to use IDLE.
Anyway, very good tutorial beeg
