Python
  Home arrow Python arrow Page 4 - Python Operators
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
Moblin 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PYTHON

Python Operators
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-01-14

    Table of Contents:
  • Python Operators
  • The Prestigious Mathematical Operators
  • The Judgmental Comparison Operators
  • Boolean is Not a Type of Broth
  • Assignment Operators

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    Python Operators - Boolean is Not a Type of Broth


    (Page 4 of 5 )

    Boolean operators let us test if a value or more than one value is true. The AND operator says if this AND that are true, do this. The OR says if this OR that is true, do this. And Not is for inverse values.

    Let's apply these to our majestic beer program:


    #!/usr/local/bin/python

    beers = 0

    timmy = 20

    tommy = 20

    drunk = timmy+tommy

    if beers == 0 and drunk < 100:

    print "Did you guys drop a beer or something?"

    elif beers <20 or drunk >80:

    print "There aren't enough beers here to make you look good. Fortunately for you I am desparate."

    else:

    print "Glug glug glug"

    Bitwise and Shift

    We are going to skip the Bitwise and Shift functions for now, as those are mainly for low-level programming, and mostly what we will be learning is high-level programming. For now, just know that they exist on a plane far cooler than the one you do.

    More Python Articles
    More By James Payne


       · Thanks for stopping by and reading my article on Python Operators. Here we discuss...
       · Well not that I know a durn thing about Python, but it appears to me beers = 99 on...
     

       

    PYTHON ARTICLES

    - SSH with Twisted
    - Mobile Programming in Python using PyS60: UI...
    - Python: Count on It
    - Python Strings: Spinning Yarns
    - Python: More Fun with Strings
    - Python: Stringing You Along
    - Python Operators
    - Bluetooth Programming in Python: Network Pro...
    - Python Sets
    - Python Conditionals, Lists, Dictionaries, an...
    - Python: Input and Variables
    - Introduction to Python Programming
    - Mobile Programming in Python using PyS60: Ge...
    - Bluetooth Programming using Python
    - Finishing the PyMailGUI Client: User Help To...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway