Python is very easy to use and it can be used for arithmetic operations. in this section lets look how we can use python as a calculator. This section is described three sections.
Python Basics 01 :- Python Oprerators
Python Basics 02 :- Python Data types, Variables and other basics (This will be discussed in next section)
Python Basics 01 :- Python Operators
An operator is a symbol that is used for calculations. In simple 3 + 5 3 and 5 are operands and + is the operator.Python language supports following type of operators.
- Arithmetic Operators
- Comparision Operators
- Logical (or Relational) Operators
- Assignment Operators
- Conditional (or ternary) Operators
Python Arithmetic Operators
Operator
|
Description
|
Example
|
+
|
Addition - Adds values on either side of the operator
|
a + b will give 30
|
-
|
Subtraction - Subtracts right hand operand from left
hand operand
|
a - b will give -10
|
*
|
Multiplication - Multiplies values on either side of
the operator
|
a * b will give 200
|
/
|
Division - Divides left hand operand by right hand
operand
|
b / a will give 2
|
%
|
Modulus - Divides left hand operand by right hand
operand and returns remainder
|
b % a will give 0
|
**
|
Exponent - Performs exponential (power) calculation on
operators
|
a**b will give 10 to the power 20
|
//
|
Floor Division - The division of operands where the
result is the quotient in which the digits after the decimal point are
removed.
|
Now let's see some examples in python IDE. (click here to see how the python GUI is opened)