So trying to learn some python. I had a couple of people recommend this course.
So I started to run through it on Friday. First two lessons were not that bad. Basic “print” statements to start followed by “comments/#” usage.
So far so good right? In comes lesson three, math with python. Most of the basic functions were easy to pick up. Multiplication, division, addition, subtraction and of course the proper order of operations. It also goes into > greater than, >= greater than or equal to, < less than, <= less than or equal to, and finally % percentage/remainder. Or at least I think it’s supposed to be remainder.
It is this final piece that has been kicking my butt. So I get that the modulus (%) is for remainder, I can’t figure out how it works.
The formula for the exercise is ” 100 – 25 * 3 % 4″ the answer is 97.
So I’m still trying to figure out how this works before I move on. Of any of you out there can point out a good explanation feel free to let me know.
Or once I figure it out I’ll update.
Update
Ok, so with the help of a coworker it looks like I’ve figured this out. So the “%” means divide by following number, but use the remainder for the next piece of the equation.
So what that means for the above equation:
100 – 25 * 3 % 4
100 – 75 % 4 ( which means 75 / 4 which is 18.75, but not using floating points yet, so it’s 18 remainder of 3)
100 – 3
97
And I’m sure my Algebra I teacher would be happy I showed my work…