>>> (1+2)**2 9 >>> (2+3*4)/2 7 >>> 7%3 # % is the modulo operator 1 >>> 7 == 7 True >>>
>>> "Andrew" + " " + "Dalke"
'Andrew Dalke'
>>> "*" * 10
'**********'
>>> "My name is %s. What's your name?" % "Andrew"
'My name is Andrew. What's your name'
>>> "My first name is %s and family name is %s" % ("Andrew", "Dalke")
'My first name is Andrew and family name is Dalke'
>>> "My first name is %(first)s. Is yours also %(first)s?" % \
... {"first": "Andrew", "family": "Dalke"}
'My first name is Andrew. Is yours also Andrew?'
>>> "Andrew" == "Dalke"
False
>>>
>>> [1, 2] + [3, 4] [1, 2, 3, 4] >>> [1, 2] * 3 [1, 2, 1, 2, 1, 2] >>>
2+3*4; # evaluates to 14, multiplication has precedence over addition (2+3)*4; # evaluates to 20, parentheses force the precedence
>>> True and True True >>> True and False False >>> False and True False >>> False or True True >>>
This page based on Operators