Question :

What are the different arithmetic operators used in Python?

What do you mean by precedence of operators? Give examples.

Subject

Python

Standard

Computer Science Engineering

Views

781

Asked By

Dashboard

Mukesh
Answer / Solution

The different arithmetic operators used in Python are: *,/, +,-, %,**,and //.

Precedence of arithmetic operators in decreasing order

  • () (Parentheses)
  • **(Exponentiation)
  • - (Negation) (Division)
  • // (Integer Division) * (Multiplication) % (Modulus)
  • +(Addition) - (Subtraction)

Operator precedence determines which operator is performed first in an expression with more than one operator with different precedence.

Precedence of operators:

  • () (Parentheses)
  • **(Exponentiation)
  • - (Negation) (Division)
  • / (Division),* (Multiplication), % (Modulus), // (Integer Division)
  • + (Addition) - (Subtraction)
  • <, >, <=, >= Comparison operators
  • == , !=
  • Logical NOT
  • Logical AND
  • Logical OR
Krishav
Answer / Solution

 Python will always evaluate the arithmetic operators first (** is highest, then multiplication/division, then addition/subtraction). Next comes the relational operators. Finally, the logical operators are done last. This means that the expression x*5 >= 10 and y-6 <= 20 will be evaluated so as to first perform the arithmetic and then check the relationships.

The following table summarizes the operator precedence from highest to lowest. 

Level

Category

Operators

7(high)

exponent

**

6

multiplication

*,/,//,%

5

addition

+,-

4

relational

==,!=,<=,>=,>,<

3

logical

not

2

logical

and

1(low)

logical

or


Top Trending Questions


Recent Question Update

Connect python to mysql database
looping structure in python
What are the rules for naming a variable?
What are the rules for naming a variable?
Write any four features of Python.
What is the role of indentation in Python
Explain IDLE and its main purpose.
Which are the applications of Python?

Advantages Of NCERT, CBSE & State Boards Solutions For All Subjects

  • All the NCERT Solutions have been prepared by academic experts having 10+ years of teaching experience.
  • They have prepared all the solutions in simple and easy language so that each and every student can understand the concepts easily.
  • All the solutions have been explained step to step-wise in details with better explanations.
  • Students can also use these question and answers for your assignments and in homework help.
  • All the solutions have been explained in detail and the answers have been compiled in a step-wise manner.
  • All the questions and answers are commonly prepared according to the Latest Syllabus of Board Education and Guidelines.
  • Students can know about the various types of questions asked in the exams with the help of these solutions.

Top Course Categories