Arithmetic operators in python 3

In this tutorial, you will learn about arithmetic operators in python and arithmetic operator examples. These operators are used with numeric values to perform the operations like Addition (+), Multiplication (*), Division (/), Subtraction (-), Modulus (%), Exponentiation (**) and Floor Division (//) in python. If multiple operator are taking place we need to use the parenthesis (). For arithmetic operator we will take a simple example of addition where we add two digits. The asterisk (*) is the token used for multiplication, and ** is the token used for exponentiation (raising a number to a power).

  1. Parentheses have the highest precedence and can be used to evaluate in the order you want. Since expressions in parentheses are evaluated first, 2 * (3-1) = 4.
  2. Exponentiation has the next highest precedence, so 2**1+1= 3 and not 4.
  3. Multiplication and both Division operators have the same precedence, which is higher than Addition and Subtraction, which also have the same precedence. So 2*3-1= 5 rather than 4,

 

python arithmetic operators example :-


Suppose ‘4’ and ‘5’ are two operands then addition is,
x=4
Y=5
Print(x+y)
O/p:-
Output is 9.

Similarly we can use for other operators as Multiplication (*), Division (/), Subtraction (-), etc.

Additional Services : Refurbished Laptops Sales, Python Classes, Share Market Classes And SEO Freelancer in Pune, India