r/learnpython • u/[deleted] • Apr 03 '20
Python programming made me better at and more interested in math
I was never really good at math, in fact i hate math. Ironically, I really love computers, and most people always say programming computers requires loads of math skills, and tbh i think thats kind of a yes and no type of thing.
I dropped out of high school and always failed math classes but after getting my GED and just wanting to find a career and being obsessed with computers, I decided i might as well get good at that, but learning to code was so hard, it made no since to me at all, than i just kept trying to learn python.
ive been trying to learn python for literally years, i work fulltime and am a full time college student and im just now becoming mediocre at python, but im pretty proud lol.
what I noticed though is as i learned how python works, how the step by step instructions work, how the logic works, it actually helped me become better at doing math, and in turn doing the math helped me get better at python, im just talking college algebra though, but thats pretty amazing thinking i went from failing high school math, and than passing college level math courses, I didnt really even understand what variables were, like in algebra, assigning values to letters and symbols? wtf
Than i learned how python works and something just clicked, I was actually INTERESTED, in computer code, so learning concepts for it, no matter how hard (because i am kinda dumb) was worth it to me because i wanted to be good with computers lol. The programming concepts and math concepts for school went hand in hand, I mean I even program simple scripts to do math equations for me, because what is a mathematical formula? Its (to me, a simple guy really) a step by step instruction on how to solve an equation. This is really prevalent in algebra, im not familiar with other types of mathematics though, but think of the formula step by step, how you do the arithmetic, its easy to make python do exactly how your brain does it, step by step, line by line.
what im trying to figure out though, is what mathematical concepts should i study more of to be a better coder? In college i was forced to start out at a basic algebra level cause i was so bad at math, but as i learned to code i went from basic algebra, to a technical math class that im actually passing, and I have one remaining math class that im required to take to get my dual degrees, what kind of math should i study for my last class? I actually have a broad choice, but i thought of taking college level algebra,
I assumed college algebra would probably help me the best as a programmer, I also plan to take python courses as my programming language of choice for my cyber security degree! (we have a choice of like 20 programming languages, after you take computational thinking first.)
what mathematical concepts really helped you understand python or code in general?
5
u/Lord_Dizzie Apr 03 '20
I read your title as meth and I immediately needed to know what kind of Python you are into...
Math can potentially discourage a lot of programmers. Sometimes I think when people refer to math in regards to computer science, it's almost used as a gatekeeping device. You don't need to be great at math to be a great programmer, but it definitely helps to be math oriented.
1
u/BearandSushi Apr 04 '20
I want to learn Python but math is the thing that keeps me from doing anything computer science. Not only do I despise math but numbers to me are just...foreign. Like i can't do simple arithmetic in my head. People keeps telling me that math is just a language you just gotta keep at it but at what point do I just accept it's not for me?
1
Apr 05 '20
I literally used to think the same way, but it is kinda like a language, if you keep practicing at mathematics, you eventually can use the fundamentals you keep learning on more complex problems, you will be able to break down equations into segments and solve problems easily,
3
u/kapitalsnow amateur; started learning cuz i was bored in quarantine Apr 03 '20
agreed. being good at math helps, but definitely not necessary. you can have a great career as a programmer without getting straight As in math.
7
u/PhilipYip Apr 03 '20
I'd advise getting used to the numeric python library numpy. You should be totally comfortable with vectors, understanding the axes and explicitly setting vectors to rows or columns when needed. You should also be used to working matrices and able to perform common element by element operations (+,-,*,/,//,%,^) and array operations (@) as well as the basic statistics (sort, sum, mean, mode, var, std, prod, cumsum, cumprod and diff) which can be done using the different axes of a matrix and also linear algebra (interpolation problems are a good example).
15
u/dan4223 Apr 03 '20 edited Apr 03 '20
This guy dropped out of school and failed math the classes while he was there and you want to drop matrices on him? How about making sure he has a firm grip on algebra and basic logic first.
I think some Khan academy videos could help. 
1
Apr 05 '20
LOL yeah some of the stuff he said i didnt quite get, but a lot of it actually is stuff ive already been dabling in.
1
u/kingsillypants Apr 03 '20
Eh, if he's smart enough to code solutions to algebraic equations in python he can easily pick up the basics of matrices and operations such as gauss Jordan elimation, solving equations via matrices. The basics arent exactly rocket science. At op - theres a fantastic lecture in linear algebra by an older grey haired mit professor. Let me know if you want me to send a link to him.
1
Apr 05 '20
yes please send that link lol, i listen to lectures like that in the background when i do homework
1
-1
u/kingsillypants Apr 03 '20
Eh, if he's smart enough to code solutions to algebraic equations in python he can easily pick up the basics of matrices and operations such as gauss Jordan elimation, solving equations via matrices. The basics arent exactly rocket science. At op - theres a fantastic lecture in linear algebra by an older grey haired mit professor. Let me know if you want me to send a link to him.
2
u/LeastFavoriteLife Apr 03 '20
Can you send the link to me please.
2
1
u/kingsillypants Apr 03 '20
1
u/LeastFavoriteLife Apr 03 '20
Thank you!
1
u/kingsillypants Apr 03 '20
No problem mate.
Linear Algebra is beautiful. You'll learn how to solve equations in a different way, you never would have thought of.
It also lends itself to many other branches of mathematics and problems and to be able to see a master explain is nothing short of amazing.
Let me know if you want to hear of a 7 year old genius, solved a difficult problem. (think of mathematicians as sports stars) and he jumped from the free throw line, at 7 years old.
14
u/KerbalSpark Apr 03 '20 edited Apr 03 '20
A good choice for me was to write RayMarching renderings. And optimize them for faster work. I mined math treasures in the depths of math libraries. All these matrices, vectors, tricks for faster calculations and approximations. Also i looked at panoramas (spherical, skyboxes and other) and metods for render and conversions between it.
5
u/MastersYoda Apr 03 '20
I dont have much to contribute, but adjacent and maybe a little along your path, go check out project euler, you can solve mathematical problems using programming. You can also go into a math course that takes you towards algorithms, I dont know what math courses that entails, Google it! Computers/programming love algorithms.
4
u/NoYcETODOI Apr 03 '20
Project Euler according to me is the best source to transcend the math barrier in programming. Solving questions helped me realise how effective mathematically optimised algorithms were as compared to brute force algorithms. Learned a bit about cryptography through the initial questions. Loved it Cheers
4
u/llc_Cl Apr 03 '20
That kind of growth is awesome to experience, and I agree with you about having an interest facilitates the learning of something you’re not naturally inclined to learn. In a way I feel like that’s the secret to learning anything; find out a way to learn it that won’t require a ton of energy to do so.
I can relate to your experience with math too. Personally, discrete math helped me the most. It’s all about manipulating, managing and organizing individual bits of information. Programming was fairly difficult prior to that, and it still is; programming is hard. But, it’s like discrete math forces you to understand how information can be structured effectively, especially concerning things dealing with logic. In a way, discrete math changed my life, because it teaches you how to ‘slice’ information up into tinier pieces, or how to recognize tinier bits of information. It’s good for programming because it allows you to itemize everything that your code needs to do, while also seeing the overarching picture of it. I used to really struggle with breaking tasks down into smaller, individual steps.
My path to programming was similar to yours. I was completing pre reqs for another degree and after taking some math courses I realized I liked it, took a programming class and fell in love. I mostly program in C, but am learning python because there’s so much that can be done with it. Not to mention, it doesn’t require memory management which is awesome.
3
u/MeursaultAAC Apr 03 '20
I think what you're saying really makes sense and is a shared feeling with many people not only programmers... I would expect one of the reasons explaining this feeling is the difference between the very abstract math you learn in class which doesn't provide direct application and how you use these maths techniques tools to solve problems in programming.
The interplay between theory and application is really important to really grasp a concept and I don't see how you can enjoy something you don't really understand... I hope the way math is taught in education will shift towards something more enjoyable using animations like what 3B1B is trying to do and get more context while you're learning. I think linear algebra is probably a fundamental that would help a lot of programmers.
3
Apr 03 '20
A choice have started with is the c programming language because virtually that's the programming language experts in programming recommed for a beginner like myself, it's been awesome as of yet, loving math too.... my attitude level is 60%, above average, right? So, committed to the progress and am glad no body cares......
2
u/phi_beta_kappa Apr 03 '20
OP, might I suggest the following (free) online course - Essential Math for Machine Learning: Python Edition. Currently going through it and its bringing back a lot of the math from my undergrad stats courses I've since forgotten.
1
u/cosmodrammma Apr 03 '20
i feel the same way. always hated math, i think bc i never had a place to apply it practically/meaningfully in my life. but as i've been getting more into programming, and data analysis, i'm finally seeing how meaningful it is (to my life lol)
linear algebra is a great place to start. and there's a bunch of free resources online (like khan academy, this free course/textbook)
1
u/ave_63 Apr 03 '20
I am a community college math teacher who was bad at math in HS, but then also got good at math after learning programming. When I teach math, I try to focus on concepts that loosely apply to programming.
For example, when evaluating multi-step expressions like (3+2*(4.5-2))/(3^2 -2), I try to get students to type the whole thing into one line on the calculator, to get practice matching parentheses, and getting the order of operations right. This is a useful skill even if they just use something like MS Excel and don't ever do real programming.
Another example: Try to get students to analyze functions from the inside out. For example, f(x) = 3*(x-4)^2+2. Starting with (x-4), which is 0 when x=4, and so 3*(x-4)^2 is 0 at x=4 and positive elsewhere. Thus the minimum value of f(x) is f(4)=2. This is more or less the same kind of thinking that you use when analyzing a line of code.
1
1
u/nalisarc Apr 03 '20
You know I had a similar experience and it has inturn helped me learn new math skills. Now whenever I'm taught a new math concept I try my best to make a version of it in python, which happens to be a good learning tool for both. Though I still have some trouble with some things, for example a lot of calculus I still have to do by hand because I couldn't find a satisfactory way to do some things.
1
u/Rehmannia_ Apr 03 '20
I just want to say thank you for this post!
I failed maths in school, but I want to get into coding and data science. I have statistics, calculus and algebra courses signed up for, but I find the whole thing very intimidating and overwhelming. Knowing that coding Python without extensive maths experience can be done and they both can work together like that is inspiring and motivating.
1
u/CreatureWarrior Apr 03 '20
This. I really struggle with math and I have to understand why it works in order to remember and use it. But Python helped me understand the logic a lot of things. Math is still hard, but understanding the logic behind new formulas is becoming easier and easier.
1
1
u/Alex_Jinn Apr 03 '20
A lot of teachers just lecture and do example problems without focusing on practical reasons for knowing math. As a result, kids who don't have much life experience just don't see the point.
1
u/qivi Apr 08 '20
Everyone, please don't simply believe you suck at math. It might be true, but more likely you didn't see a reason to care much or you were simply too young. Many friends believed for years, that they suck at math and at some point learnt this was not true. My girlfriend studied physics, to the great disbelieve of her high-school teachers and has now a PhD in theoretical physics. We basically pulled a friend through high-school math, some years later he was coaching others. So, if you feel like, give it a try :-) </motivational_rant>
Regarding your question, I was in the same boat, I wanted to learn programming since childhood, but never found a proper reason. But I was always good at math, so once the math problems I was working on became suitable for solving by computer, I learnt programming :-) Now, for me (as a physicist) Python helps exploring ideas quickly. If I am looking at data, I can easily simulate random data to compare my data to. Or if I play with differential equations I can quickly get solutions or even optimize parameters.
0
Apr 03 '20
[deleted]
15
7
u/capybarasleigh Apr 04 '20
Love this, but “discrete maths” is very vague!
Eg, many college intro to discrete maths classes will cover topics in mathematical logic, set theory, probability, and computability topics, while giving a brief mention of model theory, and maybe graph or category theory. Not a deep dive into any.
A lot of these can be approached conceptually, without the usually mandatory prerequisite of at least Calculus I. Which makes no sense to me. Algebra, geometry, and trigonometry made a hell of a lot more sense after some pretty basic reading in logic, set theory, and number theory. Calculus I is a lot easier with some basic conceptual background in classical physics.
Especially for experienced coders, I think their formal maths learning will be immensely easier after poking around Wikipedia, watching some lecture videos, and taking a look at something like Vellman’s “How to Prove It”: http://users.metu.edu.tr/serge/courses/111-2011/textbook-math111.pdf
But logic is easily my strongest aptitude within maths that I’ve discovered so far, so I maybe overgeneralizing.
2
u/sinewalker Apr 11 '20
Exactly this.
I would say to OP: Have a look at the turtle graphics module for python, study trig and geometry using the turtle to draw angles and measure distances. This leads to areas inside shapes, and intersecting shapes, which is a cross-over between geometry and set theory (and more generally calculus, but we don't need it yet).
In fact the overlay and interplay between set theory, boolean algebra, logic and lambda calculus was something that facinated me in junior high school once I saw it (by using LOGO for fun at home; curiously it was never pointed out to me in school until year 11, and again at university). Insights like this are so important, and to me it was a step-up, and a motivation that I was lucky to have.
8
2
Apr 03 '20
Just a beginner and keen to have mistakes corrected. Soln: Query your program with various inputs and tabulate the time taken against input. This then becomes a problem in regression.
0
Apr 04 '20
[deleted]
2
u/prithvidiamond1 Apr 06 '20
Yes, I understand why the solution is correct as we just need to know how much time printing hello world takes (as it is the main process we are concerned with and the added delay due to the input is not of concern in terms of output of the program).
I will have to temporarily end my answers here. I have been very busy lately but thanks for the questions. I wasn't aware of the halting problem until recently when you sent the link explaining what it is as a part of the original question. I am still not fully satisfied with my understanding of the halting problem (I have some doubts about it in some ways). I will have to do a bit more research into it before I can answer the other questions!
Once again, thanks for broadening my knowledge!
2
u/owlbois Apr 03 '20
Question. What if we're really, really bad at maths, or suspect we have dyscalculia?? I've been wanting to get into Python for a while but knowing that I'm going to run into maths makes me wonder if I should even bother at all. Simple arithmetic mostly eludes me (addition is OK but subtraction, multiplication, and division are a nightmare), and 'simple' 'x = a2 / b, now find the value of b' algebra makes me cry................
2
u/TeamSpen210 Apr 03 '20
The sort of math you end up needing is rather different to what you'd do by hand - computers are really good at doing the calculation part, it's mostly about telling them what to do. Depending on the kind of program you want to write, it may or may not involve much math at all. If you do need an equation, you can usually just find it somewhere or even use the computer to solve it itself.
2
Apr 04 '20
Bro, if I could give you gold I would. That was a great, well detailed list of examples and really showcased the beauty of it all. Cheers!
1
u/prithvidiamond1 Apr 03 '20
I am only interested in the last problem... The other part of your comment while excellent for OP or any other beginner, is trivial for most people who have been at it for more than a year seriously... Would it be by determining time complexity of the input part and the multiplying the exact time constant of the input part and then it becomes an exact expression (a mathematical function) that can determine the time based on the number of characters... I would not assume this to be the most accurate method but it would not be too far of either.
0
Apr 04 '20
[deleted]
2
u/prithvidiamond1 Apr 04 '20
Ok thanks, looks like I have overthinked this one...
0
Apr 04 '20
[deleted]
2
u/prithvidiamond1 Apr 04 '20
Of course, what better thing to do when I am in quarantine and bored, lol, thanks!
1
0
u/my_password_is______ Apr 04 '20
no idea why this post is getting so many upvotes
millions of people do those things everyday without knowing linear algebra and graph theory and calculus
seriously, how many excellent artists know linear algebra and calculus and use it while painting LOL
17
u/goishen Apr 03 '20
I was interested in math until we got to complex numbers. If they can make up imaginary numbers, so can I.