well ok here we go (i might change bits later)
ok python= programming language which you type in code into something like notepad and it makes it into code but you can do graphics aswell if you get pygame and easygame (ill explain later) when you run it the python module will get the code out of the text pad you just wrote it in and run it... so as from request i have just explained what python is (as if anyone didnt know.... this is the programming section)
ok first note . i have just begun programming so i can only give you a push start. and second i make mistakes so if i left out a bit in a code point it out
First thing is to download python 2.3 ( not 2.4 2.3 ok?)
www.python.org and the reason its 2.3 i want you to download is that if your going to make games or any graphics with python you will need ... sort of a plugin for it. the too programs you will need are easygame and pygame.
search the net for those and pygame comes with an install file and easygame ; well put all the files in the easygame folder you download in the python folder
Just as a note to people. programming is not about learning commands that make you do cool stuff. programming is being creative about the commands you have to make the program do what you want to do.
ok now first open python IDLE and you will see loads of version stuff at the top and a space to type under neath. now first off when you write the code python will run the code so it is python that is doing the work and running it. to make it a program as such you should compile it which basicly takes python code that runs it and sticks it to the program and makes it an exe. now we will start codding.
Ok i will say stright off that my website teaches you to program so if i left anything out go to
www.sparkicks.com and learn to program page.
ok now go to file and new window and save that as : whatever you want here.py
now type in
and press f5 or go to run and run module. it prints hello world. now that is the first step that usually all programming tutorials take. (the hello world bit) they usually use that to show the print command.
now , to explain something new. There is a thing called a varible. it is basicly like x and y. it represents things. only in maths you dont know what it is. its like a box and you can store something in it and look at it during the program and change it. so to make a varible we say
variblenamehere= "hello world"
Code: Select all
hehehellowhateveryouwant= "this is what is in the varible"
Now you will notice at this stage that i used "" around my thing to say . well this is because i want the program to know it is words im saying it to write not a varible. if i say
it will say what the varible --- is equal to. if i said
it would actually print the word (well not exactly a proper word now but anyway) hehehellowhateveryouwant. so whatever is in a "" is called a string. so try this code
Code: Select all
whatever1= "yes i am good"
whatever2= "yea yea yea whatever"
heheidontknowwhattocallthisone= "yawn"
print "this is a string and im going to print a varible now"
print whatever1
print whatever2
print heheidontknowwhattocallthisone
*lets breath out* ok now that we have that done i want you to fiddle around with printing varibles and strings and one more thing. to print 2 things on the same line say
Code: Select all
print "string here " + "another string " + andvariblehere
another thing. varibles cant have spaces in them and they must start with a letter (the letter part i strongly believe but not 100% sure)
ok so once you have done all that fiddling we will be doing an if command
the way it works its
Code: Select all
if hehe== "yes":
print "hehe is yes"
Main Mistakes :
no : at the end of an if command
to say something is = to somethin just use one = if you are saying if it is equal to something you say ==. the other thing to add to an if command is the else command. if whatever the condition is , is not met then do this
eg
Code: Select all
answer= "yes"
if answer == "yes"
print "ans is yes"
else:
print "ans is not yes ans is something else"
now usually i would tell people at the start of the program but .. well the only excuse is that i forgot.
usually you would have loads of lines of code when you get programing and its confusing when you want to edit a bit of it. so first make your work spaced out and leave nots after code
Code: Select all
varible2= "the house" # this is the varible that says what item i have in my bag....
so use # to write a line that is not included in the code but is still there you can use it after a code or on a new line, your choice
now back to the if command. you may want to check a number of things lets say you were at a hotel and you wanted to ask was there a double bed. and if there wasnt ask for a single bed and then if nither of those worked a couch? well here is how
elif
its like else but if the if or elif is true that is asked above it then it doesnt ask
Code: Select all
answer= "ok"
if answer == "yes ":
print "why thank you"
elif answer== "mabey":
print "thanks"
elif answer == "ok":
print "sure"
elif answer== "fine":
print "*sign* ok"
else :
print "why didnt you say something positive ?!?!?!"
now did you realise that by the time it got to elif answer == "ok" and so on that after it finished out that command it finished. it didnt go onto the next elif or else.try it now and see also you dont need to do answer== every time and a print everytime you could make it make lets say eg
Code: Select all
make= "yes"
if make== "yes":
new= "well whatever you want it to be"
elif new= "well whatever you want it to be"
print "oh you already have a varible called new"
sry i got to go now ill be back later to write more