JythonTutorial:2 Arithmetic
Arithmetic
In Python you have the following arithmetic operators:
Symbol  Name 

+

Addition 


Subtraction 
*

Multiplication 
/

Division 
''

Floor division 
%

Modulo 
'''

Power 
Now, let's try to use Python as a calculator. We will calculate $3*8/6$:
Here are a few more examples:
The rules of arithmetic precedence are the same as with calculators; Python evaluates expressions from left to right, but things enclosed in brackets are evaluated first:
Elementary functions
You can also do some calculations using builtin elementary functions. For this we will need to import a module (i.e. peace of code) which contains such functions. For elementary functions, we will need to import the module math which has elementary functions. Let calculate $\sqrt{100}$:
Note we call "math.sqrt", not simply "sqrt".Alternatively, you simply import all functions (in this case you do not need to type "math." on front of each statement
Let us consider a logarithmic function:
Exercise: Change 100 to some other number and check the output 
The math module provides access to mathematical constants and functions.
How do we know which functions can be used? There is a special command "dir()" which prints all implemented Python functions in the module "math":
Run this commands and you will see familiar math functions of Python
Largest numbers
Let us find out max and value for integer numbers:
Exercises:
Exercise: This code has as a mistake. Correct this code and calculate the absolute value of 100 