How to do Python math at command line?

PythonServer Side ProgrammingProgramming

Python is an interpreter based language. When you invoke Python interprter, (>>>) Python prompt appears. Any Python statement can be entered in front of it. As soon as you press ENTER, the statement is executed.Hence a mathematical expression using operators defined in Python will be evaluated at command line.

>>> 2+4
6
>>> 6+9/3
9.0
>>> 100%3
1
>>> 56//5
11
>>> 2**5
32
raja
Published on 23-Feb-2018 10:26:44
Advertisements