Syntax
keywords | example | |
---|---|---|
Assignment | ||
Functions |
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 |
Types
Numbers
functions are defined in the following modules:
import module | ||
---|---|---|
floating point numbers | math | |
complex numbers | cmath |
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}