Python/programming introduction 02-11-2013, 07:57 AM
#1
I'd like to start out this thread with a few simplicities if you will.
Firstly, you may have been told constantly "go with this language, go with that language" and so on.
But let me point some thing out, most languages are really the same.
(NOTE: I said most.)
They usually have their if, and else statements.
And they have their own version of print.
An example would be as follows. Java
And Python
Granted with a language like java you must learn extra "rules" as I'll call them.
But what I'm getting at is if you learn a language basics, and learn it's rules and so forth, then you can apply that knowledge to almost any language, as long as you have the API.
For your reference I'll post the API, for python.
http://docs.python.org/3/library/
Now another thing you need to take note of, some languages require indentation.
Whereas some do not.
Sadly python is one language that requires it.
But indentation isn't so bad once you get used to it.
In most languages (maybe all because I'm not that experienced yet.)
You just indent your line of code if it works with another line (an example will be shown later on.)
Now my tools as a programmer. http://www.emeraldeditor.com/
http://www.oracle.com/technetwork/java/j...index.html just get both the jdk and jre from there.
http://www.python.org/download/releases/3.3.0/ just scroll down and get the proper one for your computer.
Now emerald editor comes with it's own instruction documents for setting up java, so I won't go further into that.
but for python we go into: tools --> preferences --> user tools
Then click on a sign that says empty, and on menu text just type whatever you want to go there.
On command C:\Python33\pythonw.exe (although just click the button next to command, because your python file might not be where mine landed, so instead of getting frustrated just search yourself)
argument $(FileName)
initial dir $(FileDir)
hot key whatever key you want.
make sure capture output, and save before execute are check marked. and leave the rest blank.
SO once that's out of the way let's go ahead and do a bit more advanced programming.
Now that's that for the tutorial (so far)
I plan on adding on to it, and making it bigger and better.
And even formatting it.
Firstly, you may have been told constantly "go with this language, go with that language" and so on.
But let me point some thing out, most languages are really the same.
(NOTE: I said most.)
They usually have their if, and else statements.
And they have their own version of print.
An example would be as follows. Java
Code:
public class javatest{
public static void main (String[] args){
System.out.println("Hello World");
}
}And Python
Code:
print("Hello World!")Granted with a language like java you must learn extra "rules" as I'll call them.
But what I'm getting at is if you learn a language basics, and learn it's rules and so forth, then you can apply that knowledge to almost any language, as long as you have the API.
For your reference I'll post the API, for python.
http://docs.python.org/3/library/
Now another thing you need to take note of, some languages require indentation.
Whereas some do not.
Sadly python is one language that requires it.
But indentation isn't so bad once you get used to it.
In most languages (maybe all because I'm not that experienced yet.)
You just indent your line of code if it works with another line (an example will be shown later on.)
Now my tools as a programmer. http://www.emeraldeditor.com/
http://www.oracle.com/technetwork/java/j...index.html just get both the jdk and jre from there.
http://www.python.org/download/releases/3.3.0/ just scroll down and get the proper one for your computer.
Now emerald editor comes with it's own instruction documents for setting up java, so I won't go further into that.
but for python we go into: tools --> preferences --> user tools
Then click on a sign that says empty, and on menu text just type whatever you want to go there.
On command C:\Python33\pythonw.exe (although just click the button next to command, because your python file might not be where mine landed, so instead of getting frustrated just search yourself)
argument $(FileName)
initial dir $(FileDir)
hot key whatever key you want.
make sure capture output, and save before execute are check marked. and leave the rest blank.
SO once that's out of the way let's go ahead and do a bit more advanced programming.
Code:
#bazinga is our "variable" we have it defined, using the = sign. int declares what type of number we are using.
#which by using int it would be any "real number" (if I remember math class correctly)
#example being 1, 2, 3, 4,.
#But there's float which would be say 1.01 and so on.
#Now input means the Variable equals what the user inputs into the command.
#and the words surrounded by quotes and parentheses is just basically the instruction to the user, telling them what to do next.
bazinga = int (input("Pick a number any number."))
#this is an "if statement" it tells the computer if bazinga (which is the number you input) is greater than or equal
# to 3 then print bingo
if bazinga >= 3:
print ("Bingo!")
#The else statement is saying if the above is false, and the number is less than 3 then print "Try again"
else:
print ("Try again")Now that's that for the tutorial (so far)
I plan on adding on to it, and making it bigger and better.
And even formatting it.
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)
![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)
![[Image: Wfxdx.png]](http://i.imgur.com/Wfxdx.png)