Python as a calculator
In Python we can perform different evaluations with ease by using IDLE, which is known as Interactive Development Environment of Python. Let us discuss the following:
The arithmetic operations include addition, subtraction, multiplication and division. For example-
If we give only one operator then the respective operation will be performed easily. But in the case of multiple operators (in the above code 2+3*4-5) then the expression is evaluated on the basis of operator precedence.
Calculating Floating point expressions
In Python we can perform calculations on floating point numbers and this is shown in below:
You can check if a value is equal to other value.
Working with Powers
We can express the power of a particular number by using ** or with the pow( ).
Working with Complex numbers
Complex numbers are those which exist in the form of a+ib or a+bi. As integers and floating point numbers, the complex numbers also supports the arithmetic operations by using +,-,* and / operators.
Working with Trigonometry
To access the trigonometric functions first we need to import math module. The import is a key word in python that helps to import the related modules. The math module is one amongst those modules. It comprises of various mathematical functions. Here we have shown two example functions in math module.
In interactive mode, the last printed expression is assigned to the variable ‘_’. This means that when you are using Python as a desk calculator, it is somewhat easier to continue calculations, for example: