=>> This is 2.2 section of Python tutorial, and i am going to tell u about Python as a calculator. yes,we can use Python shell or any Python IDE as a calculator.
Link of previous linked tutorial
-> 2.1 : https://dev.to/mohit355/python-basics-3cjd
-> 1.2 : https://dev.to/mohit355/download-and-install-python-3-x-1boo
=>> Python is perfectly suited to do basic calculations.
**Along with addition, subtraction, multiplication and division, there is also support for more advanced operations such as:
- (+) : Addition
- (-) : Subtraction
- (*) : Multiplication
- (/) : Float division ,return decimal value as output
- (//) : Integer division ,return integer value as output
- (%) : Modulo ,it will gives reminder
- (**) : Exponent In above figure some addational operations shown but don't worry these are function which is predefined in Python that will be discussed later in this series.
Why Python as a Calculator ?
#Ans- .This is because we need not to code many number of line to sum two number or divide or multiply.
we can directly print it using print function. (print function is already discuss in previous post).
For example,
- I want to add three number 2,3 and 4. so we directly use print(2+3+4) and its output is 9 as shown below.
let's perform following operations : 2+3-4/2
we can simply done this by print(2+3-4/2) and its output is shown below.
Its print 3.0 because here we use float division and it always return a decimal value4%2 output is 0 (% used for the reminder) 4%2 means when 4 is divided by 2 what is the reminder left.
let's perform 4**2 means 4 to the power 2 and the output is 16.
=>> So we can do any type of mathematical calculation using simply print function.
=> If you have any problem let me know that in comment box.
Thank You...
Top comments (0)