Click The Picture Below To Vote For ViralCo!
|
| | Programming tutorial :S for those people who doesnt belive me | |
| | Author | Message |
---|
xkristjanx
Posts : 15 Join date : 2008-06-07
| Subject: Programming tutorial :S for those people who doesnt belive me Mon Jun 09, 2008 5:00 pm | |
| So, I'm bored, so I decided to write a VERY basic python tutorial. In this tutorial, you'll learn a few things. So let's get started.
The most basic thing that you can do in Python is to make words/letters appear on the screen. We do this using the 'print' method. This is how it works.
Code:
print "Hello, world!" # Whenever you use a "#", this message is considered a comment, and is therefore NOT put into the code.
Combined with the print function, there is also 'while', 'if', 'else', and 'elif'. The while function continues to do (insert code here) until whatever you put after while is false. For instance, if I wrote :
Code:
pie = 3.14 while pie == 3.14: print "Hello, world!" # Note that you can give words values by putting your_word_here = whatever_you_want. When you want to print that variable, this is how you do it.
Code:
pie = 3.14 print pie # Note that when you print variables, you do NOT have to use quotations. But, when you're establishing a variable with letters and words inside of it, you must start with " and end with "
The If function:
The if function can do a few things. First, it will see IF this condition is true. If the condition is true, it will run whatever code you have beneath it. For example,
Code:
pie = 3.14 if pie == 3.14: print "Hello!"
The Elif function:
The elif function, basically, means else if. So, say you have your first block of code, and it has the while function. But you wanted to make something else happen, if the while statement did not come true. Basically, the elif function checks the statement above it, and if it is false, it will rune whatever block of code is inside of it. For example:
Code:
pie = 3.14 while pie == 3.14: print "Hello!" elif pie != 3.14: print "Error."
# Note that as long as you are running this exact code, there is no possible chance to get to the eilf statement. The != means NOT equal to. Unless someone messes with the source code, you have a perfectly working program.
Finally, the else statement. Basically, when you use else, it runs its block of code when all other blocks are false. For example :
Code:
pie = 4.13 while pie = 3.14 print "Pie is 3.14" else: print "Pie is not that. Pie is actually 3.14"
So, I hope this tutorial has helped you out, and good luck programming! | |
| | | Hunter[GM] Admin/Owner
Posts : 185 Join date : 2008-05-22
| Subject: Re: Programming tutorial :S for those people who doesnt belive me Mon Jun 09, 2008 10:04 pm | |
| - xkristjanx wrote:
- So, I'm bored, so I decided to write a VERY basic python tutorial. In this tutorial, you'll learn a few things. So let's get started.
The most basic thing that you can do in Python is to make words/letters appear on the screen. We do this using the 'print' method. This is how it works.
Code:
print "Hello, world!" # Whenever you use a "#", this message is considered a comment, and is therefore NOT put into the code.
Combined with the print function, there is also 'while', 'if', 'else', and 'elif'. The while function continues to do (insert code here) until whatever you put after while is false. For instance, if I wrote :
Code:
pie = 3.14 while pie == 3.14: print "Hello, world!" # Note that you can give words values by putting your_word_here = whatever_you_want. When you want to print that variable, this is how you do it.
Code:
pie = 3.14 print pie # Note that when you print variables, you do NOT have to use quotations. But, when you're establishing a variable with letters and words inside of it, you must start with " and end with "
The If function:
The if function can do a few things. First, it will see IF this condition is true. If the condition is true, it will run whatever code you have beneath it. For example,
Code:
pie = 3.14 if pie == 3.14: print "Hello!"
The Elif function:
The elif function, basically, means else if. So, say you have your first block of code, and it has the while function. But you wanted to make something else happen, if the while statement did not come true. Basically, the elif function checks the statement above it, and if it is false, it will rune whatever block of code is inside of it. For example:
Code:
pie = 3.14 while pie == 3.14: print "Hello!" elif pie != 3.14: print "Error."
# Note that as long as you are running this exact code, there is no possible chance to get to the eilf statement. The != means NOT equal to. Unless someone messes with the source code, you have a perfectly working program.
Finally, the else statement. Basically, when you use else, it runs its block of code when all other blocks are false. For example :
Code:
pie = 4.13 while pie = 3.14 print "Pie is 3.14" else: print "Pie is not that. Pie is actually 3.14"
So, I hope this tutorial has helped you out, and good luck programming! This isn't VCO related but nice guide. Stickied, Locked and moved to Off-Topic | |
| | | | Programming tutorial :S for those people who doesnt belive me | |
|
| Permissions in this forum: | You cannot reply to topics in this forum
| |
| |
| |
|