Python Python Basics Types and Branching Numeric

Nils Kriedner
Nils Kriedner
Front End Web Development Techdegree Student 17,777 Points

Question about the PEMDAS formula Craig is explaining

Hey fellow coding students and teachers,

I don't really see how the „PEMDAS“ formula that Craig is presenting in the video is working in his example:

10 - 3 * 5 + 8 = 3

I understand how the result is 3 by calculating

(( 10 - ( 3 * 5 )) + 8 = 3

But according to the „PEMDAS“ formula the addition („A“) would have to be calculated before the substaction („S“).

So if this „PEMDAS“ formula would really be applied it should be:

10 - (( 3 * 5 ) + 8) = -13

Or am I missing something?

Isn't it that addition and substraction are equal and will just be calculated in the order they appear (and not according to the PEMDAS order)?

Would be happy if someone could clear my confusion.

You get an upvote for sure for your answer. :-)

2 Answers

Dave StSomeWhere
Dave StSomeWhere
19,768 Points

Isn't it that addition and substraction are equal and will just be calculated in the order they appear (and not according to the PEMDAS order)?

Yes (MD and AS are equal and processed left to right)

Below is from Math is Fun

P - Parentheses first E - Exponents (ie Powers and Square Roots, etc.) MD - Multiplication and Division (left-to-right) AS - Addition and Subtraction (left-to-right)

Divide and Multiply rank equally (and go left to right).

Add and Subtract rank equally (and go left to right)

bot .net
bot .net
11,469 Points

Hi mate!, as far as i know in math u start substraction or addition for the left to the right, if it’s an + from the left u do this first, then the right side.

addition and substraction are equal , but u add or substract by which come first from the left side. first the (), than * /, and only then + - - this is the priority.

if this help mark as best answer