0
Using the mathematical operations which operation we have to use first.
according to mathematics first we have to perform the division, then multiplication, then addition then subtraction, but in this lesson I was instructed that I have to perform the operation first which are in the parentheses. what to do
3 Respuestas
+ 1
Hello, acording to my knowleage of math, you should first perform operations in all parentheses in usual order {[( / * - + )]} and then all other operations in same order. Parentheses are used to break the usual order of operations because sometimes you need more compex calcation
+ 1
parentheses override normal order.
>>> 3*5+7
22
>>> 3*(5+7)
36
0
In Python there is some form of operator precedence. They are listed [url]https://docs.python.org/3/reference/expressions.html#operator-precedence[/url] for python 3.
As you can see. addition and subtraction are equal. So are multiplication, division and remainder although they do precede add and sub.
Because Python has a lot of operators. Many people use parenthesis. They make it explicit which calculations should be done first. This i.m.o greatly improves readability.