Wednesday, March 4, 2009

Variables

Variables are a very important part of the python programming language.

They work very much like variables in algebra. You can set anything not used by python as a variable.

For example, using a as a variable works because it is not already a command. You can also use more than one letter, like abcdefg as a variable.

Making variables is easy. Just type:

abcd = 4

This is just an example. You can use almost any variable name, as long as it isn't used by python. so "print" is a bad variable name, but "print_object" could work.

You can also set the variable to words, not just numbers. For example:

abcd = 'example'

Just make sure to put the quotation marks around the text.

Next Post : raw_input()

No comments:

Post a Comment