# define function to pause in tutorial def pause(): raw_input('...') print '\n'*24 # boolean conditions in Python print "type(True), type(False)" print type(True), type(False) pause() # negation print "not True" print not True pause() # in print "0 in [1,0,2]" print 0 in [1,0,2] pause() # in print "'a' in 'test of a phrase'" print 'a' in 'test of a phrase' pause() print "'ra' in 'test of a phrase'" print 'ra' in 'test of a phrase' pause() print "'z' in 'test of a phrase'" print 'z' in 'test of a phrase' pause() # and print "5>2 and 6>1" print 5>2 and 6>1 pause() # or print "5>1 or 1>=6" print 5>1 or 1>=6 pause() # also considered False print "Also treated as False are other empty or zero types ..." print "None # empty object reference" print "0 # the number zero (also 0.0)" print "[] # empty sequence" print "'' # empty string" print "() # empty tuple" print "{} # empty dictionary" pause() # regular expressions print "Also, can use regular expressions using Python's re module" print "import re" print 'print type(re.match("[0-5]e", "3e"))' import re print type(re.match("[0-5]e","3e")) pause() print 'print type(re.match("[0-5]e", "3f"))' print type(re.match("[0-5]e","3f")) pause() print "def f():\n if re.match('ab','c'): print 3\n else: print 4" print "f()" def f(): if re.match('ab','c'): print 3 else: print 4 f() pause()