Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
553 views
in Computer by (53.9k points)

Give example to understand operator precedence available in Python programming language.

1 Answer

0 votes
by (90.2k points)
selected by
 
Best answer

Following example to understand operator precedence available in Python programming language :

#!/usr/bin/python

a = 20

 b = 10 

c = 15 

d = 5 

e = 0 

e = (a + b)*c/d #(30*15)/5 

print “Value of (a + b) * c / d is “, e

e = ((a + b) * c)/d #(30*15)/5 

print “Value of ((a + b) * c) / d is “, e

e = (a + b) * (c / d); # (30) * (15/5) 

print “Value of (a + b) * (c / d) is “, e

e = a + (b*c)/d; # 20 + (150/5) 

print “Value of a + (b * c) / d is “, e

When you execute the above program it produces following result:

Value of (a + b) * c / d is 90 

Value of ((a + b) * c) / d is 90 

Value of (a + b) * (c / d) is 90 

Value of a + (b * c) / d is 50

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...