Saturday, October 1, 2016

[Basic Concept] Simple Operations


>>> 2 + 2

The space around the plus and minus signs here are optional (the code would work without them)

>>> 2 * (3+4)
14

>>>10/2
5.0


Using a single dash to divide numbers produce a decimal (or float)


>>>-7
-7


Divided by zero produces error

>>>11/0
error

In Python , the last line of an error message indicates the error's type

No comments:

Post a Comment