ThePythonGameBook

learn Python. Create Games

User Tools

Site Tools


en:glossary:v:variable

Variable

Imagine a money box with the description “coffee money”. Imagine there are some coins (total: 4.76 Euro) in this box. The variable with the name “coffee money” has now a value of 4.76 Euro.

Python is clever enough to find out if there is a string (text) or a number in a variable. Unlike other programming language, you do not have to declare the type of a variable before you can assign values to that variable See: dynamic typing.

naming of variables

You can name your variables (and functions, classes etc.) pretty much however you like, as long as you stick to those rules:

built-in keywords

and       del       from      not       while
as        elif      global    or        with
assert    else      if        pass      yield
break     except    import    print
class     exec      in        raise
continue  finally   is        return
def       for       lambda    try

built-in functions

Built-in Functions
abs() divmod() input() open() staticmethod()
all() enumerate() int() ord() str()
any() eval() isinstance() pow() sum()
basestring() execfile() issubclass() print() super()
bin() file() iter() property() tuple()
bool() filter() len() range() type()
bytearray() float() list() raw_input() unichr()
callable() format() locals() reduce() unicode()
chr() frozenset() long() reload() vars()
classmethod() getattr() map() repr() xrange()
cmp() globals() max() reversed() zip()
compile() hasattr() memoryview() round() __import__()
complex() hash() min() set() apply()
delattr() help() next() setattr() buffer()
dict() hex() object() slice() coerce()
dir() id() oct() sorted() intern()
/var/www/horst/thepythongamebook.com/data/pages/en/glossary/v/variable.txt · Last modified: 2014/01/09 11:07 (external edit)