Python

Syntax

  keywords example
Assignment    

Functions
Objects

def return yield
class
 
Call    
Conditinal if elif else
and or not
 
Loops for else
in
while else
break continue
for i in range(0,5)
for i in xrange(0,5)
Exceptions try except finally
raise
 
Other reseved words pass
import from
global
del
exec
assert
is
 
  lambda
print
 

 

Types

Numbers

python numbers

functions are defined in the following modules:

  import module  
floating point numbers math  
complex numbers cmath  

Collections

python collections

String

s = 'abc'

or s = "abc"

slicing:

s[0:1] gives 'ab'

s[1:] gives 'bc'

s[:1] gives 'ab'

Tuple

t = (1,2,3)

Lists

l = [1,2,3]

Dictionary

d = {'first':1,'second':2,'third':3}


metadata block
see also:

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Visual Basic .NET for Microsoft Platforms only.

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 

cover Dark Basic Professional Edition - It is better to get this professional edition

cover This is a version of basic designed for building games, for example to rotate a cube you might do the following:
make object cube 1,100
for x=1 to 360
rotate object 1,x,x,0
next x

cover Game Programming with Darkbasic - book for above software

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2017 Martin John Baker - All rights reserved - privacy policy.