Python Tutorial: PEMDAS rule

Tuesday, 4 April 2023

PEMDAS rule

PEMDAS rule can be used to simplify complicated  numerical expressions with more than operations.

Very simply way to remember PEMDAS rule!

----> Parentheses

----> Exponent 

M ----> Multiply

----> Divide

----> Add

----> Subtract

1. In a particular simplification, if you have both multiplication and division, do the operations one by one in the order from left to right.

2. Multiplication does not always come before division. We have to do one by one in the order from left to right.

3. In a particular simplification, if you have both addition and subtraction, do the operations one by one in the order from left to right.

Evaluate each of the following numerical expressions.

Problem 1 :

(3 * (4 + 2)) * 5

Solution :

= (3 *  (4 + 2)) * 5

= (3 * 6) * 5

= 18 * 5 

= 90

Problem 2 :

(4 * (16 – 1)) – 6

Solution :

(4 * (16 – 1)) – 6

= (4 * 15) – 6

= 60 - 6

= 54

Problem 3 :

5 + (6 + (7 * 2)) // 5

Solution :

= 5 + (6 + (7 × 2)) // 5

= 5 + (6 + 14) // 5

= 5 + 20 // 5

= 5 + 4

 = 9

Problem 4 :

3 – (-2 + 7) + 4

Solution :

= 3 – (-2 + 7) + 4

= 3 – 5 + 4

= -2 + 4

= 2

Problem 5 :

(18 // 3) * (-2)

Solution :

= (18 // 3) * (-2)

= 6 * (-2)

= -12

Problem 6 :

2(7 – 13) – (6 - 12)

Solution :

= 2(7 – 13) – (6 - 12)

= 2(-6) – (-6)

= -12 + 6

= -6

Problem 7 :

-6 * (2 – 7)

Solution :

= -6 * (2 – 7)

= -6 * (-5)

= 30

Problem 8 :

–(14 – 8) // (-2)

Solution :

= –(14 – 8) // (-2)

= -6 // (-2)

= 3

Problem 9 :

-18 – (8 – 15)

Solution :

= -18 – (8 – 15)

=-18 – (-7)

= -18 + 7

= -11

So, the answer is -11.

Problem 10 :

-52 // (6 – 19)

Solution :

= -52 // (6 – 19)

= -52 //  (-13)

= 4

Problem 11 :

(38 - (-4))/(6 * (-7))

Solution : 

= (38 - (-4))/(6 * (-7))

= (38 + 4)/(-42)

= 42/(-42)

= -1.0

Problem 12 :

(28 - (-3 * 4))/(10 * (-2))

 

Solution :

= (28 - (-3 * 4))/(10 * (-2))

= (28 - (-12))/(-20)

= (28 + 12)/(-20)

= 40/(-20)

= -2.0

 

Input Equation:
= 14+18/2*18-7
= 14+
9.0*18-7
= 14+
162.0-7
176.0-7
169.0

 

Input Equation:
= 10-9*24/8*6
= 10-
216/8*6
= 10-
27.0*6
= 10-
162.0
-152.0

 

Input Equation:
= 15*18+12/3+9
270+12/3+9
= 270+
4.0+9
274.0+9
283.0

 

Input Equation:
= 10/5+10-9*11
2.0+10-9*11
= 2.0+10-
99
12.0-99
-87.0

Input Equation:
= 8*4+9-9+18
32+9-9+18
41-9+18
32+18
50

Input Equation:
= 3*19*14+18/2
57*14+18/2
798+18/2
= 798+
9.0
807.0

Input Equation:
= 11*11-6*17+4
121-6*17+4
= 121-
102+4
19+4
23

Input Equation:
= 10*12-14/2+15
120-14/2+15
= 120-
7.0+15
113.0+15
128.0

Input Equation:
= 2-1+5*4*11
= 2-1+
20*11
= 2-1+
220
1+220
221

Input Equation:
= 14/2-1+3
7.0-1+3
6.0+3
9.0

Input Equation:
= 16*7*15+11+17
112*15+11+17
1680+11+17
1691+17
1708

Input Equation:
= 9+15/5*13

= 9+3.0*13
= 9+
39.0
48.0

Input Equation:
= 12/3*12+10

4.0*12+10
48.0+10
58.0

Input Equation:
= (11+42-5)/(11-4)

= (53-5)/(11-4)
= (
48)/(11-4)
48/(11-4)
= 48/(
7)
= 48/
7
6.8571428571429

(use only 1 or 2 decimal)

Input Equation:
= 16*15/5+12

240/5+12
48.0+12
60.0

Input Equation:
= (9+33-6)/6-3**2

= (42-6)/6-3**2
= (
36)/6-3**2
36/6-3**2
= 36/6-
9
6.0-9
-3.0

Input Equation:
= (6+3)**2+(9-10/5)

= (9)**2+(9-10/5)
9**2+(9-10/5)
= 9**2+(9-
2)
= 9**2+(
7)
= 9**2+
7
81+7
88.0

Input Equation:

= (24+21*(12%9)+12-6)+36

= (24+21*3+12-6)+36

= (24+63+12-6)+36

(87+12-6)+36

= (99-6)+36

= 93+36

=129

 

Input Equation:

=(1+4)**2-(2*9%6+8)

=5**2-(2*9%6+8)

=25-(2*9%6+8)

=25-(18%6+8)

=25-(0+8)

=25-8

=17

Input Equation:

= 20 * 4 * 2 *7 - (18%14*6)

= 20 * 4 * 2 *7 - (4*6)

= 20 * 4 * 2 *7 - (24)

= 80 * 2 *7 - (24)

= 160 *7 - (24)

= 1120-24

= 1096

Input Equation:

=120 + ((9/3) % (72/8))**2

= 120 + ((9/3) % (9))**2

= 120 + ((9/3) % (9))**2

= 120+(3.0%9)**2

= 120+3.0**2

= 120+9.0

= 129.0  

                   Input Equation :

= 120 + ((9%3) % (72/8))**2

= 120 + ((9%3) % (9.0)**2

= 120 + ((0) % (9.0))**2

= 120 +(0.0)**2

= 120 + 0.0

= 120.0

Input Equation:

= 18%12//24*23-12+8*6

= 18%12//24*23-12+48

= 6//24*23-12+48

= 0*23-12+48

= 0-12+48

= -12+48

= 36

 

Input Equation:

= 18%12%24*23-12+8*6

= 6%24*23-12+8*6

= 6*23-12+8*6

= 138-12+8*6

= 126+8*6

= 126+48

= 174

 

 

Solve the following advanced order of operations problems:

1. (24+21*(12//9)+12-6)+36

= (24+21*(12//9)+12-6)+36
= (24+21*(
1)+12-6)+36
= (24+21*
1+12-6)+36
= (24+
21+12-6)+36
= (
45+12-6)+36
= (
57-6)+36
= (
51)+36
87

 

2. 20-12-4-2+5(8+9)**2

Input Equation can be rewritten:
= 20-12-4-2+5*(8+9)**2
= 20-12-4-2+5*(
17)**2
= 20-12-4-2+5*
17**2
= 20-12-4-2+5*
289
= 20-12-4-2+
1445
8-4-2+1445
4-2+1445
2+1445
1447

3. (1+4)**2-(2*9/6+8)

Input Equation:
= (1+4)**2-(2*9/6+8)
= (
5)**2-(2*9/6+8)
5**2-(2*9/6+8)
= 5**2-(
18/6+8)
= 5**2-(
3.0+8)
= 5**2-(
11.0)
= 5**2-
11.0
25-11.0
14.0

4. 20 * 4 * 2 *7 - (18//14*6)

Input Equation:
= 20*4*2*7-(18//14*6)
= 20*4*2*7-(
1*6)
= 20*4*2*7-(
6)
= 20*4*2*7-
6
=
80*2*7-6
=
160*7-6
=
1120-6
=
1114

5. 120 + ((9/3) / (72/8))**2

Input Equation:
= 120+((9/3)/(72/8))**2
= 120+((
3.0)/(72/8))**2
= 120+(
3.0/(72/8))**2
= 120+(3.0/(
9))**2
= 120+(3.0/
9)**2
= 120+(
0.0)**2
= 120+
0.0**2
= 120+
0.0
120.0

 

6. (1+12*4)**2 - (22*4-12)**2

Input Equation:
= (1+12*4)**2-(22*4-12)**2
= (1+
48)**2-(22*4-12)**2
= (
49)**2-(22*4-12)**2
49**2-(22*4-12)**2
= 49**2-(
88-12)**2
= 49**2-(
76)**2
= 49**2-
76**2
= 49**2-
5776
2401-5776
-3375

7. 18/12//24*23-12+8*6

Input Equation:
= 18/12//24*23-12+8*6
1.5//24*23-12+8*6
0.0*23-12+8*6
0-12+8*6
= 0.0-12+
48
36.0

8. (40 - 3 - 5)**2 + (12/4*6)**2

Input Equation:
= (40-3-5)**2+(12/4*6)**2
= (
37-5)**2+(12/4*6)**2
= (
32)**2+(12/4*6)**2
32**2+(12/4*6)**2
= 32**2+(
3.0*6)**2
= 32**2+(
18.0)**2
= 32**2+
18.0**2
= 32**2+
324.0
1024+324.0
1348.0

9. ((12//8-4)**2)**2 - 12**2

Input Equation:
= ((12//8-4)**2)**2-12**2
= ((
1-4)**2)**2-12**2
= ((
-3)**2)**2-12**2
= (
9)**2-12**2
81-12**2
= 81-
144
-63

 

 

No comments:

Post a Comment