# python includes the basic and, # or, and not boolean operations a = 10 b = 20 c = 30 if a>9 and b+1==21 and c==a+b: print "boolean 'and' example equates true" if a==9 or b<10 or c<100: print "only one of these expressions needs to be true" if not a+b==31: print "if this is not true"
A python example based blog that shows how to accomplish python goals and how to correct python errors.
Showing posts with label oriented. Show all posts
Showing posts with label oriented. Show all posts
Wednesday, November 18, 2009
Python - boolean and, or, and not
Tuesday, September 15, 2009
Python - multiple inheritance
<pre> <span class="comment"># multiple inheritance with python....its easy!span> <span class="comment"># in addition to multiple inheritance you shouldspan>
<span class="comment"># check out the creating static methods for a classspan> <span class="ANY_KEYWORD">classspan> Arm(object): <span class="ANY_KEYWORD">defspan> flipBird(self): <span class="ANY_KEYWORD">printspan> <span class="STRING_LITERAL">"span><span class="STRING_LITERAL">extend middle fingerspan><span class="STRING_LITERAL">"span> <span class="ANY_KEYWORD">classspan> Weapon(object): <span class="ANY_KEYWORD">defspan> fireWeapon(self): <span class="ANY_KEYWORD">printspan> <span class="STRING_LITERAL">"span><span class="STRING_LITERAL">rat tat tatspan><span class="STRING_LITERAL">"span>
<span class="comment"># with your span><span class="comment">powers combined I am Hero Arm (part arm part weapon!)span> <span class="ANY_KEYWORD">classspan> HeroArm(Arm, Weapon): <span class="ANY_KEYWORD">passspan> a = HeroArm() a.fireWeapon() <span class="comment">#output:span> <span class="comment"># rat tat tatspan>
a.flipBird() <span class="comment">#outputspan> <span class="comment"># extend middle fingerspan> pre>
Subscribe to:
Posts (Atom)