Does coding require math
Here are some posts Iâve seen on the r/learnprogramming subreddit forum:
How much math do you need to become a good programmer?
Should I brush up on math?
This may be the dumbest question I have ever posted online. How much math does one actually need to be a good programmer?
Math and python programming have a somewhat misunderstood relationship. Many people think that you have to be good at math or made good grades in math class before you can even begin to learn programming. But how much math does a person need to know in order to program?
Not that much actually. This article will go into detail about the kinds of math you should know for programming. You probably know it already.
For general programming, you should know the following:
Addition, subtraction, division, and multiplication â And really, the computer will be doing the adding, subtracting, dividing, and multiplying for you anyway. You just have to know when you need to do these operations.
Mod â The mod operation is the âremainderâ and its sign is usually the % percent sign. So 23 divided by 7 is 3 with a remainder of 2. But 23 mod 7 is 2.
The even/odd mod test trick â If you want to know if a number is odd or even, mod it by 2. If the result is 0, the number is even. If the result is 1, the number is odd. 23 mod 2 is 1, so you know 23 is odd. 24 mod 2 is 0, so you know 24 is even. If x mod 2 is 0, you know that whatever number is stored in the variable x is even.
To get a percentage of a number, multiply that number by the percent number with the decimal point in front of it. So to get 54% of 279, multiple 0.54 * 279. This is why 1.0 often means 100% and 0.0 means 0%.
Know what negative numbers are. A negative number times a negative number is a positive. A negative times a positive is negative. Thatâs about it.
Know what a Cartesian coordinate system is. In programming, the (0, 0) origin is the top left corner of the screen or window, and the Y axis increases going down.
Know the Pythagorean theorem, and that it can be used to find the distance between two points on a Cartesian coordinate system. The Pythagorean theorem is a^2 + b^2 = c^2. What this usually means in programming is the distance between coordinate (x1, y1) and (x2, y2) will just be sqrt( (x1 â x2)^2 + (y1 â y2)^2 ).
Know what decimal, binary, and hexadecimal numbering systems are. Decimal numbers are the numbers weâre used to that have ten digits: 0 to 9. Itâs commonly thought that humans develop this system because we have ten fingers and counted on our fingers.
Computers work with binary data, which is a number system with only two digits: 0 and 1. This is because we build computers out of electronics components where itâs cheaper to make them only recognize two different states (one state to represent 0 and the other to represent 1).
The numbers are still the exact same, but they are written out differently because there are a different number of digits in each system. Because hex has 6 more digits than the 0-9 numerals can provide, we use the letters A through F for the digits above 9. The easiest way to show these number systems is with an odometer. The following three odometers always show the same number, but they are written out differently in different number systems:
You donât even have to know the math of converting a number from one number system to another. Every programming language has functions that can do this for you.
(On a side note, hexadecimal is used because one hexadecimal digit can represent exactly four binary digits. So since 3 in hex represents 0011 in binary and A in hex represents 1010. This has the nice effect that the hex number 3A (which is 58 in decimal) is written in binary as 00111010. Hex is used in programming because it is a shorthand for binary. Nobody likes writing out all those ones and zeros.)
And thatâs about it. Other than the number system stuff, you probably already knew all the math you needed to know to do programming. Despite the popular conception, math isnât really used that much in programming. You would need to know math in order to write programs that do, say, earthquake simulators. But thatâs more about needing to know math for earthquakes rather than needing to know math for programming an earthquake simulator.















