Wednesday, 8 January 2014

Arithmetic Expressions

An arithmetic expressionconsists of operands and operators combined in a man-ner that is already familiar to you from learning algebra. Table  shows several arithmetic operators and gives examples of how you might use them in Python code.


In algebra, you are probably used to indicating multiplication like this: ab. However, in Python, we must indicate multiplication explicitly, using the multi-plication operator (*), like this: a * b. Binary operators are placed between their operands (a * b, for example), whereas unary operators are placed before their
operands (-a, for example).


No comments:

Post a Comment