What type of math should I learn to code in Python?

Hello there everyone :wave:

I have a very general (and likely quite naïve) question:
What type of math should I learn to code in Python?

For further context, I’m interested in eventually working in machine learning and have interests in data analytics and data viz.

I understand that Python does a lot of the math for you, but I’m curious to know the types of math that will help me become a better programmer and problem solver, along with becoming acquainted with the mathematics that serve as the backdrop to so many applications today.

Thanks in advance for your time and advice!

IMO I think that it’s helpful to have a basic understanding of statistics (for hypothesis testing) and linear algebra for ML. BUT, that said, don’t let that intimidate you. I think there’s a common assumption that one has to be a math genius in order to be a programmer or data scientist and that’s just untrue. I think if one has a general understanding of the mathematical concepts behind what you’re programming then that’s really helpful.


Completely agree with Lisa! For machine learning and data analytics, I would say the following are particularly important:

  • Basic algebra (for understanding general[ized] linear models and interpreting regression coefficients)
  • Logarithms (for data transformations and model interpretation)
  • Linear algebra – specifically matrix algebra (for understanding and implementing/interpreting ML models)
  • Summary statistics and how to interpret/calculate them (eg., mean, median, mode, standard deviation, MAD, percentiles, range, etc.)
  • Rules of probability (eg., how to calculate/interpret joint probabilities, conditional probabilities, etc.)
  • Probability distributions, expectation & variance (most important are probably normal/gaussian, student-t, binomial, bernoulli, chi-square, and poisson)
  • Sampling distributions and standard errors

If you’re interested, here is a packet I made for incoming students in my masters program (in statistics and data science) outlining all the major math topics that were necessary for success in the program. I think it’s a pretty good list of topics – although I don’t actually think it’s necessary for data analysts to be able to calculate derivatives or integrals by hand (it just helps to understand what they are if you want to go back and re-derive formulas/understand how ML algorithms work under the hood).

Hope that helps! As a math person turned data scientist, I love this question :slight_smile:


Thank you for this! I was hoping that you would chime in here. :smiley:

1 Like

Thanks @lisalisaj! I appreciate the advice :grin:

@sophsommer3 I really appreciate the thoroughness of your post, and the super helpful linked packet! Thank you so much for taking the time to offer your advice and for sharing your materials :raised_hands:

Do you or @lisalisaj have any recommendations on texts or other resources that cover these topics exceptionally well?


Looking at the direct question, ‘to learn code in Python?’ we could start with the very basics. Let’s pretend we’re still young and a long ways off learning college maths. One would hope that we have fundamental numeracy skills and can add/subtract, multiply/divide, compute percentages, understand negative numbers and fractions. Those are all covered by the time we get to middle school, and enough to have under our belt when we begin to learn Python (or programming in general).

More important, believe it or not is literacy skills and communication. Learning a language means having to read a lot, learn a mountain of new terms, grapple with syntax and through it all compose notes that we can decipher down the road. Strong communication skills are a definite asset so what we read makes sense. If this is a problem, then deal with it first, not while you are learning.

Python does not do math for us. We do math with Python (or any language) by drawing on basic constructs and as we progress, the built in math functions that come with the language. We won’t be reaching for those functions to begin with, just using the basic operators and learning the algorithms to achieve our goal (like the sum of a list, &c.).

It certainly does not hurt to learn math fundamentals alongside the programming, and a segue into more serious learning may be necessary at some point in time. Having a full set of math skills already won’t make one a better programmer, but it will remove one of the hurdles when it comes to integration of math concepts and programming.

Then there is the other piece of the puzzle… Science in general. It’s through studying nature that we learn the math of the universe, the real relationships that make up the physical world. Math is the language of science, so don’t be afraid to enhance your scientific knowledge on the weekends while you get a break from this learning.


Thanks for the insights @mtf :slightly_smiling_face:

Do you have any recommended texts, particularly for enhancing my scientific knowledge on the weekends?

1 Like

Not sure what’s out there but one could start at the beginning…

science for beginners

Many school curriculum will have a pre-science course that covers the basics of weights and measures, units, scientific method, scientific notation, &c., all of which is important to lay down as a foundation.

There is no one book given that the local library has a 500 and a 600 section that is just brimming with books. Rather than focus on specifics get in the general reading to start. Read about science history, important developments through the ages that led up to the Scientific Revolution, important milestones and significant contributors through the ages.

My personal library contains hundreds of science related books though it is mostly crated up, not nicely ordered in the 500 or 600 section like they are in the public library. Funny, though, considering I was never a scientist, just a genuinely interested bystander. Science doesn’t give us answers as much as it raises new questions. No point pursuing science if one is not curious about the world around them.

Great Experiments in Physics
Edited by Morris H. Shamos, Professor of Physics, New York University
Holt, Reinhart and Winston, Inc.

Don’t let the date on the book fool you. The experiments are much older than that and whole disciplines have emerged from them. One might be familiar with many of the names but not their accomplishments. This is foundational reading for a young scientist, but not for the faint of heart.

Bottom line, we are living in an age where the sky is the limit. Never have we had so much laid out before us. Pick a scientist a week and explore their works.


Thank you @mtf :pray:

1 Like

If you’re open to learning a little bit of R, this textbook was written by my former advisor, who is one of the best teachers I’ve ever had (I haven’t used the book myself). I also highly recommend Openintro statistics as a free online textbook for learning statistical theory. At Codecademy, there’s also the new master statistics with python skill path, which has some of this material (and will have a lot more a few months from now!).


These are great resources, thank you @sophsommer3!

Tough to let this topic go, especially if we are talking about ‘young scientists’ and ‘young mathematicians’ and ‘young theorists’. I venture to say there is every evidence in my seven year old grandson of a far more prevailing awareness than I ever had at seven.

Came across an ‘old book’ in my library called, Math Wizardry for Kids by, Margaret Kenda and Phyllis S. Williams; illustrated by, Tim Robinson; 1995. It’s published by Barron’s Educational Series, Inc., with pretty strict copyright warnings so we’ll forthwith be relying upon Fair Use guidelines. Novelty has no copyright since it is endemic in so many like minded and curious people. We don’t create ideas, we explore and create FROM ideas. That said, if your youngster wants to explore, ping this topic. This book is full of keen ideas.

1 Like

@sophsommer3 thank you for the packet! ive been thinking about a career change this past month because ive been also recently laid off due to the pandemic. ive been working laborer jobs since high school, even though my best scores were in mathematics i never did pursuit college or any degree using math. i figured now is a better time then ever to teach myself as much as i can with a 6 month goal of having my first job as an internship somewhere. long story short youve made my research time significantly smaller to know the different algorithms for what career i would like to start in!

Thank you!
A new user/ new community member :slight_smile: :heart:


Thank you so much for the resource! I am currently in a master’s in data science program, but I may switch to a different program due to the fact, that I am struggling in their bridge courses as I spend hours looking for resources on how to solve a coding exercise and or math problem. I feel the instruction in the program I am in is subpar. I was looking through your math packet, and this is so much easier to understand and can actually comprehend with fair amount of ease. This is not true with the math bridge course I will have to take if I continue with my current program. Their math course makes this math packet look like pre-algebra material in comparison. I also hear horror stories of students having to retake the class. Several students with computer science and engineering backgrounds struggle with the math course. I really do think I need to get myself into a different program, one with math, but not so insanely advanced that I’ll spend most my time pulling my hair out in frustration!


So many people have horror stories about math classes like this! I know I do… and it’s so sad that it has to be this way. Math can be really beautiful when we dig past all the complication and intimidation.

I truly believe that math is an important component of any data science curriculum. That said, I think it’s mostly a waste of time to practice deriving complicated formulas or calculating complex integrals by hand (maybe it’s helpful to do it once, just to know you can). To be an effective data scientist, it’s more important to understand the conceptual ideas and be able to implement them (which is easy to do in Python, R, or other software!). And it’s easier to learn the conceptual ideas when you’re not stuck in all the complicated details or intimidated out of taking a class.

Not just an important component, it is the language of science. Sooner or later our math illiteracy will come to bear. It is pointless to try to understand numbers and postulates in data science without the language they are expressed in. Numbers, by themselves have no meaning. Even graphs, without context have no meaning. The axes of the graph are concepts and math is our way of relating them and garnering further meaning.

If math is that important, I may be better of just going for a degree in mathematics and supplement my learning with programming courses. I live near a University that offers a hybrid computer science/math degree. It would only be a bachelor’s degree, but considering that math seems to be so important, could such a bachelor degree be just as valuable as a master’s degree when it comes to at least gaining an entry level data analyst job and then working my way towards a data scientist as I gain more skills? Or maybe take a year’s worth of math (calc1, through calc3 and two linear algebra courses) at a community college and then go for a master’s in data science? Unless anyone has techniques on how one can lean calculus 1 through calculus 3 and even more advanced topics in a 10-week period, I’d love to know such techniques. I graduated with a master’s in exercise science with a 4.0 GPA, completed a Data Analyst nanodegree from Udacity, will have my Oracle Databases SQL certification by the end of March and am going for a Tableau Certification by the middle of summer. My goal is to get myself at least an entry level data analyst job within three years. The reason why I want to go for another bachelor’s and or master’s degree is it seems most employers require or prefer a quantitative degree for even an entry level data analyst job. I have only managed to work part-time/minimum wage retail jobs since graduating back in 2017. I feel like a quantitative degree is the only way to change my luck in finding stable and fulfilling employment

We can gain quite a lot of proficiency in programming, especially with Python, without doing very much maths. Basic arithmetic can get a person quite a long ways, and once we get a handle on program logic (algorithms, mostly) we can devise our own solutions to more esoteric problems. The trickier stuff is harder to learn by rote and requires some understanding of the theories and identities that are common in applied maths.

I am in no place to advise one’s course of action, and it really depends upon aptitude and passion for the field since it wraps multiple disciplines under one umbrella. A master’s degree would only really be needed if you wanted to teach in a formal setting and would likely be mostly theoretical. The bachelor’s degree program will have enough fundamental maths to fill one’s needs, in my estimation. Kick in philosophy for the logic it entails and with good grades the doors will surely be open to you in any number of areas.

Bottom line, talk with prospective future employers and get their take on it. Somebody in my position can be only so helpful, as in not that much.

It sounds like you’ve already made a ton of good progress toward an entry level data analyst role! I actually think that the nanodegree from Udacity, SQL certification, and Tableau certification should be enough to get you to an entry level role. I also highly recommend the data analyst career path on Codecademy for extra practice. Although I have a bachelors in mathematics and a masters in statistics, I don’t necessarily recommend the same path for others. It’s always possible to take more classes and keep learning (the field is changing so quickly, we have to keep learning to keep up!), but I also think on-the-job problem-solving experience is invaluable if you can find opportunities.

I also understand that the job search can be frustrating and demoralizing. For context, even with both those degrees (and a 4.0 GPA + academic awards), I was rejected from (or never contacted by) at least 100 entry level data analyst and data scientist roles. With persistence, I ultimately ended up with three offers, but the job search wasn’t easy even with those degrees (I also know many others who experienced the same). If your ultimate goal is a data analyst job, my advice is to persistently apply to jobs and reach out to people on LinkedIn, while continuing to further your education in any way you can (whether that’s working through courses on Codecademy or taking classes toward a degree). For specific math classes, I think you’d be set with linear algebra, calc I/II, and a basic probability and statistics class (with calc II being the lowest priority). Mathematical literacy is important, but it can be learned over time.

1 Like