# operators.py # You can form an arbitrarily complex expression using operators available # in Python. I will try to give you a flavor of them here. You can find # other operators and form more complex expressions. # Note: As you can see, each new example in this tutorial uses the concepts # that we have already studied. So, you need to read the tutorial in the # order it is presented. For example, the examples below assumes that you # understand values, types, variables, assignments, etc. print 22 + 33 - 10 # Create a few variables with a value assigned to each: hour = 5 minute = 30 print hour - 2 print hour*60 + minute print (3+4)*(40/10)+100 this = "Ham" that = " and cheese" more = " for breakfast!" # The '+' operator has different meaning depending on what type of operands # it deals with. If it is dealing with numbers, it will just add as usual. # If the operands are of string type, it will concatenate the operands. print this+that+more # '==' is the operator that tests if its two operands are equal or not # The result will be True or False issame = this == that # If you are not sure of operator precedence between two operators, use # a pair of parentheses to indicate your intention like this. # 'not' is the negation operator. isequal = (not (this == that)) print issame print isequal