r/CodingForBeginners • • 1d ago

math in coding

hello everyone im about to start learning to code (python specifically) and i want to learn the math i would need for it first to make the learning process a bit easier.

any pointers would be greatly appreciated

thx for the help

6 Upvotes

15 comments sorted by

3

u/BobCorndog 1d ago

You don’t really need math knowledge unless you do stuff that involves math

1

u/codeguru42 1d ago

You don't need math for a lot if programming but it can help.

2

u/shailendra_codes 1d ago

Great news: to start learning Python, you do **not** need advanced math at all! Basic school-level arithmetic (`+`, `-`, `*`, `/`) and simple comparison logic (`>`, `<`, `==`) are more than enough to get started.

Here is the only math you actually need early on:

  1. **Basic Arithmetic & Percentages:** Addition, subtraction, multiplication, division, and remainder (`%` — useful for checking even/odd numbers).
  2. **Comparison & Boolean Logic:** Understanding `True`/`False`, greater than (`>`), less than (`<`), and `and`/`or` conditions.
  3. **Order of Operations (BODMAS/PEMDAS):** Knowing that multiplication/division happens before addition/subtraction.

You only need higher math (like linear algebra or calculus) much later if you decide to go into AI/Machine Learning or 3D game physics. Start coding right away—you will pick up the math naturally as you build small projects! 🙌
 

3

u/mjmvideos 1d ago

Really, the math comes with the domain area you are programming for. The language itself requires no math at all. Though an understanding of addition is helpful in working with loops.

2

u/TheUmgawa 1d ago

I second this. I had to write a prime-number generator for a programming class, where we had to write weekly comments on what we learned that week, and I wrote over a thousand words (including code snippets) on how I increased the efficiency of the generator, without cheating and implementing the Sieve of Eratosthenes.

Every other number is even, so you don’t even have to check those beyond 2. The largest factor of any number cannot be larger than its square root. At this point, you’ve increased efficiency by a huge amount, but you’re still checking all of the odds, even when they’re not prime, so what do you do? You build out the list of primes on the fly, then reference that array, vector, list, or whatever data structure as your modulo. I don’t recall the efficiency increases, but they were pretty significant from iteration to iteration of the program.

Most math isn’t terribly advanced. You just have to figure out how it works. By the way, it’s not (typically ) number theory, because I found those books in the library in high school, and they were not what I was looking for. It came in handy during college, but had nothing to do with anything I ever had to program (except maybe once or twice).

1

u/ninhaomah 1d ago

Start with basic Python first.

1

u/Top_Finger_909 1d ago

You do not need to know much “math” to code however if you’re intent is learning data structures and algorithms then you will need:

1.) Discrete Math: https://personal.math.ubc.ca/~PLP/book/frontmatter.html

2.) Algorithms: https://theswissbay.ch/pdf/Gentoomen%20Library/Algorithms/Algorithm%20Design%20-%20John%20Kleinberg%20-%20Éva%20Tardos.pdf

Id highly recommend starting with something like the discrete math book up top. Then the algorithm design manual by Steven Skiena, then once you are comfortable do one of Kleinberg and Tardos or CLRS (only read specific sections)

This is about as “math” heavy things can get although again you don’t need strictly need all of this

1

u/cvco210 1d ago

You don’t need to study math to learn how to code. Just start coding

1

u/wak_trader 1d ago

It really dependson what you want to do. Linear algebra understanding will be essential after a certain point for a lot of hte paths available.

1

u/dld2517 1d ago

Math for Programmers (No Starch Press).

1

u/RedAndBlack1832 1d ago

"Math" in terms of like classroom study is very domain specific. Knowing powers of two and modular arithmetic is generally helpful though. Abstractly, the "math" is more about logic and procedural thinking. Breaking things up into steps with intermediate results and representing systems as functions (the math term, not the programming term) that feed into each other.

1

u/Jeremi360 1d ago

Coding is more logic then math, you only need math for math things,
you only need to know that: `con`, `sin`, `tan`, etc. exist and when to use it,
you don't need to write them by hand or how they work under the hood.

1

u/SeaTeaching3550 1d ago

what do you exactly want to do using python ? if its AI/ML or data science, then maths is much needed otherwise you dont need maths. basic maths which i am sure you know, is more than enough for programming stuff.

But if you are planning to learn ML, you need statistics, calculus, linear algebra, probability etc

1

u/Hot_Dog2376 1d ago

General purpose? Linear Algebra.  Vectors help a lot for things that you don't even think they would at first.  

Discreet number theory if you really wanna get into it.  

1

u/JGhostThing 21h ago

I find that I used basic algebra, calculus, and trigonometry. There are some subjects that I would have liked to have known linear algebra, such as computer graphics and such.