# define some sets gis = set(['arcgis', 'mapinfo', 'qgis', 'grass', 'udig']) opensource = set(['qgis', 'grass', 'udig']) usingpython = set(['qgis', 'grass', 'arcgis']) soft = 'arcgs' if soft in gis: print 'it is a GIS software' elif soft in opensource: print 'it is opensource' elif soft in usingpython: print 'it use python' else: print 'something else...' usepython = True if soft in usingpython else False print usepython for soft in gis: print soft, '\n', '=' * len(soft) if soft in opensource: print 'it is opensource' else: print 'it is propretary' if soft in usingpython: print 'it use python' else: print 'it use something else' print '\n' len_software = [(soft, len(soft)) for soft in gis] len_software len_software = [(soft, len(soft)) for soft in gis if soft in opensource] len_software contact = {'pietro': 333123808, 'jonh': 123123123} x = 0 while x < 4: print 'a' * x x += 1 for soft in gis: print soft, '\n', '=' * len(soft) if soft in opensource: print 'it is opensource' break else: print 'it is propretary' if soft in usingpython: print 'it use python' continue else: print 'it use something else' print '\n' numerator = 1 denominator = 0.5 # change to 0 try: print numerator/denominator except ZeroDivisionError: print "Divide a number with 0 is not a valid operation!"