Python provides an interactive shell which can be used as a calculator to do various math operations and also to test python features.
To start a shell open up a command prompt (if you are in Windows ) or Terminal (if you are in Linux). Type python and hit enter. You will enter a shell with a double arrow (>>) inside it.
Note: Python version depends on what you install in your machine. You might install python 3.7+, I had already installed python 3.7.3 which is shown in the command prompt.
Lets perform some math operation in this shell
- 1. Addition (let’s add some number): Type 5 + 3 and hit enter, you will get 8 as a result
- 2. Subtraction: 5 – 3, the result will be 2
- 3. Multiplication: 5 * 3, the result will be 15
- 5. Division: 15 / 3, the result will be 5.
Lets use python to calibrate area of a triangle with height = 5 and base of 10 unit.
In the terminal type, (5 * 10) / 2 and hit enter, you will get 25.0
Similarly let’s calculate the volume of a cube with side 5
In the terminal type 5 * 5 * 5, and hit enter , you will get 125 which is the volume of the cube
Calculation of simple interest rate , formula for simple interest rate is.
SI = (P * T * R) / 100
- SI= Simple interest
- T= Time
- R= Rate of interest.
Lets say we have P=10,000, T=2 years and rate = 8%
In the terminal type
>>> p = 1000 >>> t = 2 >>> r = 0.08 >>> si = ( p * t * r ) / 100 1600.0