Conf42 Python 2022 - Online

How to use Python to create better math lessons

Video size:


This presentation is based on my master’s thesis in the field of mathematics education, which is addressing the possibilities of using python for teaching mathematics. To get to this topic, it was necessary to research the current state of using Python and other languages in the classroom in Brazil and worldwide. This made it possible to understand many of the difficulties and advantages of working with programming languages as a tool to help teachers.

Therefore, the idea is to pass on these lessons so that other educators can try to implement different experiences in their classes.


  • Jeronimo Medina Madruga will talk about how to use Python to create better math lessons. This talk will be light hearted, it won't be very technical. If you want to go deeper in some of the topics you may contact me.
  • The beauty of mathematics lies first and foremost in its ability to act as a practical tool to make sense of our complex world. We need more than ever to have students that are really good with the technical side, with math, with technology. But we need to improve the quality of our education.
  • We have to mix practical teachers and theory teaching together in order to achieve better results. A lot of math concepts are connected and scattered around the gaming world. We can also use music creation as a topic to learn math. But there are many hiccups when we see who already tried this change in education.
  • Python should not be seen only as a calculator. There are other tools to create music with Python. I'm still learning how to use Jytum, but the jytom environment has a good potential.
  • Python is not only about the language. The ecosystem around of it has so many solutions that might help you, your class, your teachers, your community, to create better lessons. Most of the time you don't really have to create something new. You have to only understand what is the right kind of package.
  • The snake game isn't only about the snake game, it's about math. We have to create digital assets and make these content around of it. Every game has a lot of math concepts behind it. If we teach today as we learned yesterday, we are robbing students of these tomorrow.


This transcript was autogenerated. To make changes, submit a PR.
Hello everyone. How are you doing? My name is Jeronimo Medina Madruga, and today we are going to talk about how to use Python to create better math lessons. Jose da Silvera Alvis is my advisor in my master's course and has contributed to the creation of this content. My masters these is in the field of mathematical educators at the Pepe match program in the Federal University of Pelotus, and it still is a work in progress, but it already gave me so much information that I use part of it to create these talk. My research is on how to use programming to teach math to teams, and at this moment, I have already read articles, papers, books and thesis from all over the world, trying to comprehend all the possibilities that technology may add to the classroom. This talk will be very light hearted, it won't be very technical, because there is so much to talk in such a short time that I think that if I went too deep in one or two tools, we would miss the whole universe that is around it. So if you want to go deeper in some of the topics, you may contact me. In the end of these talk, there is my information, my contacting information, and if anyone may not have noticed my accent, I would like to say that we are from Brazil, specifically from the south of Brazil, Hugh grand du Su. And when we talk about Brazil, it's the land of the best football there is. Especially when we say that the real football is the one that we play with our foots and the most amazing combination of samba, Captain America and Mickey, something that you never see on Disney plus. So if you notice some little failures in my english, please just know that that is my second language. And now, jokes aside, I love to work with quotes and from my favorite authors, I think that in this talk, I would be obligated to come with Kitty Yates, the author of the book the Math of Life and Death. His quote is very interesting because I think that connect with the emotion that I get when I start reading. All the experiences and many scientists and authors that have before me already went very deep in this field of knowledge. So the beauty of mathematics lies first and foremost in its ability to act as a practical tool to make sense of our complex world. That's a great invitation to rethinking our way that we view math, learning and tech, because a lot of time we just think about numbers, but we don't really connect them to our reality somehow. So I would say that this is the main topic of this talk, to rethink our relationship with math and tech. And the first question I would say that my research led me to was a traditional question, like, how do students see math? And most of us may have that impression that everybody hates math because everyone criticize it, has problems. But we are going to see that that's not really the reality. Most teachers, like this one that I'm quoting here, actually show that students like math, or most of the time they don't hate it. But it also points out that the students have problems understanding where they are going to apply the concepts. And sometimes that may be one of the motives that leads them to not understanding or even trying to go deeper in the field of math. So it's really important that educators understand that and start to see how the students see math, not only what they are trying to teach. And although we may see that students don't really hate math, at least here in Brazil, we are seeing, and most countries in development, we are seeing that the performance and evaluations of the students is not going so well. Most of these countries are suffering. Some even are not evolving. And that may be indicated by tests such as Pisa. And we have to really understand that, okay, we have students that like math, but we aren't able to improve the quality of our education. And although we are unfortunately not improving the quality of our education, we are seeing a world that needs most of our math. We are seeing that almost the new careers, new jobs that are arising within this information technology, the digital age, they are connected to the traditional Stein fields, which is science, technology, engineering and mathematics. And we might even say that some of the manual labor shall be automated in the next decade more than it has happened before. And that makes us think what we are going to do, how we are going to make this transition. We are going to have to really rethink what we are teaching, how we are teaching, because we need more than ever to have students that are really good with the technical side, with math, with technology. And that's really important. And another quote that I think that's essential to this little revolution that I'm trying to spark here is from Seth Godin in his free e book, stop stealing dreams, when he's talking about how fast the modern world has changed because of technology and the industry and everything. He says the economy has changed, possibly forever, but the school hasn't changed. So it's really important that we understand that our education, how it's functioning today, and how can we change it for the better. I'm not saying, like some may say that, oh, our education sucks, let's burn the books. Let's throw everything away. But I think that we can really do better than we are doing as of this moment. And in order to do that, we must first ask ourselves, how are we really learning math traditionally? Well, I think that everybody that has done calculus, algebra, geometry, shall remember these infinite amount of exercise that our teachers recommended to us, hundreds exercise of calculus, of integrals and euler theory. And these repetition might be essential to understand how to solve the equations and problems. But does it help us to understand what really is going on beside the numbers, beside the solution itself, what it represents in reality? How does it connect? And does that motivate the students? Or it might make them a little miserable and frustrated when they have issues. Because a lot of times some students may have trouble understanding how to calculate something, and because they don't even understand how it connects to the world around them, they just give up. And on top of that, when we are talking about math, we are mostly talking about X-Y-Z delta angles, using square root, euler and quadratic equations. But can we translate those variables to reality? Well, we can. But are we, can we connect our studies with what we see around us? Do we really understand what it's being represented in the problems that we are solving? I think this repetition and abstraction might be the first problems that we might see with the traditional education. And then we have to think, do the students really learn from this? From my personal opinion and from most that I have found from my research, I think it's safe to say that we have real issues to deal with when we talk about learning, especially when we talk about math. If we look at the numbers from universities, from schools, we may see that most subjects that are connected to math have a really high number of students who fail or drop out of classes, or even the traditional educators or course. And most of the time it's due to having a really poor foundation of these concepts that are required to understand. So we really have to change when you are talking about teens and kids, how they are learning, so they really think that they understand more math, not just, oh, I know how to use this formula, but I don't know anyway how this connects to my reality. And okay, we get that students like math, but studying math in the most traditional methods suck a little. But still, there is another piece to this puzzle, which is making the school, these teachers and the students understand how important math is in our modern world. And this meme makes me think, because sometimes we see people just reading at these screen and trying to do everything that they learn from it, or they see, I don't think that's learning most of the time. We even call it sometimes in programming, the famous tutorial hell where people just learn to repeat, repeat, repeat what they see on YouTube and other channels, other media, but they don't really think, and that's really important. In order to have a better education, we must first have to stop thinking only in solving the equations and drawing graphs for the most of our time, learning math, and really make the student a protagonist in their quest for knowledge. The student have to know what they are learning and have a genuine interest in that. And the great part about all of this is that, at least in theory, we already may have a lot of answers. We have seen the rise of many pedagogical strategies that are very easy to deal with this issue and many more, I would say, like project based learning, the famous PBL, the use of gamification, flipped classroom, and many other modern education strategies have already dealt with this problem. Most of them have in common the fact that these make the students actively seek answers and research, and sometimes even seek questions itself, and that helps to motivate them to learn more and be more engaged in the classroom. And we could talk about papers, piaget, Paul Frery, bell hooks, vigotsky, ZDP, many other classical thinkers and concepts related to education. But I will try to make a simple example out of tv series, and I really hope that I'm not giving any foiler doing so. Cobra Kai is in its fourth season now, and in order to teach the best karate, the Miyagi do and ego Feng dojos have to teach their students together, mixing their style and lessons. And that way we can relate to the concept of praxis, which is a classical concept that connects education in a way that we have to mix practical teachers and theory teaching together in order to achieve better results. We shouldn't just focus on creating something. We have to create something and at the same time try to teach the theory behind it. So we have the student engaged and learning the concepts. And that is really important. I think that most of the classical thinkers that I have said would connect a little to this Cobra Kai connection here. Okay, I think that most of us will agree with that, but how can we do that? We will have to change our approach to traditional math. Like in this example, everyone learns how to solve quadratic equation during their high school years. But do you know what you are going to do with it? Well, some of us might even still remember that we can draw a parabola from the quadratic equation. We may have the roots of the equation, the delta, and. Okay, but how is that connected to your reality, to the reality of the student? Simple example, a parabola or a quadratic equation may represent the jump of a character. Or when you throw a ball in a basketball, or anything that has movement, it can be connected to that formula. So one of the ways that we can teach quadratic equation in a way that it's not only about variables and numbers is trying to create an animation that works inside a game that may be one of the most effective was to teach. And while we are in that subject, we can see that a lot of math concepts are connected and scattered around the gaming world. For example, I am a really big fan of fighting games, especially street fighter. And in order to understand the game at its highest level, you need to understand these animations for the moves and the frame data there is so that you can work in a mathematical way of how a move should behave. How should you react, what should you bet that would be the right answer to your opponent? And so it's not only about how you can, and sure you can, it's about numbers, calculations going on all the time. And we can also use music creation as a topic to learn math, from formulas to create sounds, to compass, to rhythm, to tempo. There are many mathematical concepts involved in the creation of music. You can't have tango, pop, r and b without numbers on the background. So as we can see now, it's really easy to see mathematical concepts being used all over the world of technology. And that might be essential to develop the education for the generations that are growing up nowadays. Okay, although technology might seem the silver bullet, I have found many hiccups that might occur when we see who already tried this change in education. First of all, we have the expression these in Brazil, that when something is really expensive, like oh, can iPhone, that it costs a kidney. And well, as we can see from this slide, some math solutions really cost a kidney, especially in countries that are in development, because the exchange rate to dollar and euro and other most popular currencies is really high. So how high would it be? Well, in our case here in Brazil, $1 would be almost six hais. And if you want to think about that, you have to also think about import technology and hardware and paying license fees. And you also might even think, one of the problems is that nowadays, most software, you aren't really buying it perpetual license. You are going to buy it for one year or two years or sometime. So if you think about the cost of disclosed proprietary technology, I think that most public institutions and even most private ones would not really have a way to deal with that. And also, if we had the money that we don't have most of the time, I would have to say that a lot of these solutions based on proprietary software may be quite limited. They remind me a little bit of the calculation machine, also known as the Skinner machine, and it was one of the first machines focused on mathematical education. It was basically a machine that fed the student with a problem, allowed him to write his solution, and also gave him the correct answer after. So it indeed was useful because it allowed these student to understand if he was right or wrong. And it was created many decades ago. So in that time it was revolutionary. Today it's not so much, but still it doesn't leave a lot of room to create or explore or to understand the nature of the errors that might occur while the students trying to solve the problem. And that is really essential to a good education. Also, when we talk about disclosure solutions, most of them aren't internationalized, which means that students that aren't american or don't have English as their primary language, and even the teachers that might have to use these tools will have to deal with another setback in order to use the software learning commands and interface in another language. I have to highlight that, because here in Brazil we have really low percentage of students and teachers who are fluent in English, and that might be a really big bump on the path to a better teaching methodology. And we also have to say that in South America, the hardware costs are rising almost every day in the last few years due to the weak currents that we already have talked about due to taxes, to the pandemic, to the scarcity of components, and even competing with cryptocurrency mining, which I will never forgive bitcoin for that. But even in educators facilities that were already more structured in the past, we still have some old equipment almost everywhere. So it's vital that software solutions may be as simple was they can be, and that they can run in an open source environment, just not only on Windows or Mac. And a lot of educational facilities here still use Linux. Amen to that. Okay, that leaves the question. Buying a software package may really solve the problem related to technology. Or should we focus on another type of solution, given that these is a python conference? I really think that these is a very easy question to answer, of course. But the really big question is related not only to technology, but the whole scenario around it that we have just described it. How can we make the learning experience more effective for the students. First of all, I think that a part of this solution is really outside of the question. We need that governments, schools, universities, educators, communities and many others to understand that we need this change based on that. We need new curriculums like we can see already for quite some time and already working in England, Australia, Israel, China. I think that Sweden, I have seen Latonia and many other countries that already are trying to fit in programming and technology inside the reality of each student. It is also important that the teachers may participate in programs that may refine and update their skills and their views regarding to the usage of technology in the classroom, as we can't really make these change without the contribution of teachers. And some of them have not been around so much technology as we might have seen with the newest generations. So it's really important that we stop at this moment and say, okay, we have to first of all teach the teachers to have a different view on technology and how they are going to use it in their classroom. And in order to do that, we have to create this link between math and technology. The good news is there is a lot of people around the world already thinkinkering with new educational concepts that may build this bridge between these traditional fields. In our case, we are talking about math, but we can do this with physics, with language, with communication, with chemistry. Everything that you can think now can connect to programming and technology. And I may suggest one example from my fellow friend and colleague Rafael Spetch, who shows how to play around creating images and sound by using math and the web audio API. The link is in the source of these slide and it's essential that we risk this type of experimentation, new types of education that goes well beyond the traditional hello world when we talk about programming, because we really need students to be creative and to learn to deal with problem solving that are required traits to many of the new fields of work that are coming from this digital age. Now we can talk a little bit of already there are a lot of open tools out there and at this specific moment, I'm not going to talk about Python. There is a motive about that. And I'm going to start with logo. Logo is one of the most traditional and maybe the oldest solution that connects math and digital technology as a teachers tool. And it has already more than 50 years since its creation. So what its basics allows us to do is to work with geometry related skills by creating shapes, drawings and much more through the usage of its interpreted language, which is really easy to use and quite direct. It just feels like drawing on a board, but with your keyboard. Another tool that has been quite popular in classrooms in the last couple of years is scratch. That's created by the MIT Media lab, and it uses really simple visual blocks to create a programming language that's so simple that you just have to click and drag to create your program. And scratch has managed to be used from small kids all the way up to the university, and even to teach teachers, as we have said before, to really deal with technology in the classroom, to really use it in their reality. And it has a really simple learning curve. And it's also multi language by design, so it's really easy to everyone to use it. You can manipulate visual objects, you can interact with the user, you can calculate variables with this really simple interface. And I'm a big fan of Samaro. He's one of the creators of Sonkipi. That's an ed and also a programming language that uses the language rails under the hood. And the ide. And programming language allows us to create music, to create sample and sounds by using programming. And it's really interesting to see how many loops and variables it takes to recreate some popular songs out there. If you research a little bit about it, you can see people creating Star wars music, Mario music, everything that you may think about, there is already a little code that turns into a beautiful music. And, okay, of course, we are in a python conference. We have to talk about Python, and it would be very disappointing. Like if you go to see Spider man, no way home and finding out there were no three different Spider man in that movie, that was a lot of expectation, and I think that's also the expectation that most of us have here in this talk. And when we talk about Python and math, first thing that most people will say is that Python can be used as a calculator. And that's not wrong. That's great. But I really think that there is so much more than that we can do with it. First of all, I think that people have trouble understanding how programming languages really work. So I would like to point out a tool that's not directly connected to the math context of this talk. But it's a great tool to teach people that are starting to learn how to program. And it's called Python tutor, and it's an online tool that allows us to see how a program would work in a visual representation of variables, lists, and many other data structure that may work within a program. Next up, we have the turtle model. That gives us the ability to use logo commands and have the same resources of the original language, but this time using it within a Python environment. Well, as I have said, that Python should not be seen only as a calculator. But the truth is there is a lot of modules that are really handy in that department and we could not talk about them. One of this is the math module that allows us to use most of the traditional math functions that are defined by the C standard, like the factory of function. So a lot of things that sometimes you have to program in another language in Python, you have, oh, okay, it's already packed, you can use it. And we also have the iTEr tools module that makes it easier to calculate iterations, permutations and combinations. And we could also talk, I think, most of these time of this talk about other modules like these statistics and so on. But I decided to show the ones that I have used so far more in my research and that are more related to what I'm researching at this moment. And now going outside of the traditional Python modules, we can see a vast array of tools that our community have built for many different objectives. For example, Jyton music might be an alternative to Sonicpy, and also there are other tools to create music with Python. I'm still learning Jytum, but the jytom music environment, how to use it. But I think that it has a good potential. And another two tools that I think that is essential to talk about is the blockpy and the Ado blocks that work in a similar way. That makes scratch programming so amazing. That works with block programming. And the most interesting thing about both of these tools is that they allow to create traditional Python code so that we can use the visual programming, the block programming as an introduction to programming with Python, and make that transition from block programming to traditional programming a little easier. And now one of the most amazing tools out there is Pygame. Okay. Pygame is focused on a set of modules that make it easier to work with SDL functions, and that allows us to create games very easy and very fast. And now we are not talking about creating games as, oh, we are going to sell games. No, that's not these focus here, but allowing these students to create. And also when they are creating, these are using to be manipulating the environment and mathematical concepts around it. So that's very important. And also they can create digital assets that they might play a little after all the work is done. And if we really want to go deeper, for those thinking about data science, we have anaconda that not only is one of the best tools to install Python environment, but it's already one of the most used tools around these world in this field of knowledge, allowing an easy setup with a few commands and clicks and having the best tools out there. Most of the data science tutorials point out anaconda as their default tool. And one of the tools that are included in this anaconda package that it's worth talking about is the Jupiter notebook. If someone doesn't know it, it allows these creation of digital notebooks that might include text, image, snippets of code and much, much more, making it these ideal tool to create your digital classroom. You create really an interactive book with programming inside of it. You can really create an environment so the student can learn what are these concepts? And after it he can program and go building his portfolio of programming with these tool. And we could go on and on and on about all the tools that Python provides that are related to math, but we have not a lot of time. And also the most important thing that I would like to point here and to show is that Python is not only about the language. We have many open source languages that are great, but the great difference in my point of view is the ecosystem around of it that has so many solutions that might help you, your class, your teachers, your community, to create better lessons, to create a better classroom. Most of the time you don't really have to create something new. You have to only understand what is the right kind of package to this situation. And also, I really have to say that, don't forget the number one recommendation. Read the documentation. Most of the problems that already have been dealt with when we talk about Python modules and everything, but it's just a matter of understanding how the functions work and how the tools that you are using may help you. Okay, how can we use everything that we have just talked about? I love a simple example here to just wrap up this presentation that is creating a snake game. It's really simple and we think, oh, it's a game. What we are really talking here, we can say that it's only about 100 lines of codes that you are not going to really learn so much about it. But in the big but here, the snake game isn't only about the snake game, it's about math. And when we talk about vectors, about speed, about the direction, it's really what we are doing. When you are reading the keys and the movement, everything around that. And that is really important because most of the time when I use this example and show people how to like in an hour and a half, you can create this Python code to work as a snake game. People are really impressed, first of all, that it's really so simple to create this code. And after that they really love the fact that it's math and they don't realize it sometimes when they are building it. And that's so great. And I think that we have to have more this kind of experience in the classroom. We have to create digital assets and make these content around of it. When you are building, you are learning at these same time. And okay, I have convinced you, you are interested, you want to know more. If that's the case, I will refer you to some of my favorite material. First of all, I'm really a big can of Al swagers. He has this book. You can find most of it online and free, but if you can also buy it, that would be great. That's inventing your own computer games with Python. And it's not a book that talks directly with math, but when you see these examples, you are going to have the same kind of view that I have talked about the Snake game, that every game has a lot of math concepts behind it. And math adventures with Python from Peter Fahel. It's already one of my favorite books because it teaches so much from math that you think that you are learning Python and you are learning math with it. And that's the same experience that I get from Amit Saha. And both of them also have YouTube and also eager also was YouTube channel and YouTube videos of them talking about it. And so it's really amazing. I'm really passionate about it. I think that this is the kind of book that can really make the difference. And also I really like. It's a little old now, but I think that this video from the Pycon Australia from Liam Calloway talking about his experience of using math in the university to teach Python. It's great and it's really one of the shortest talks that I have recommended and might be even better than these talk that you are seeing here today, now. And just so we can end it all, the last quote from John Dewey, can educator that I think that summarize everything that we have talked so far in a more theoretical way. If we teach today as we learned yesterday, we are robbing students of these tomorrow. So, guys and girls, that's it. Find me or these slides. There is my contact email, Twitter, my slideshare. I will upload the slides shortly. And I have to just thank everyone for watching and hope all of you or some of you might get this passion about math and python and starting fingering and experimenting and bye.

Jeronimo Medina Madruga

IT Technician @ Universidade Federal de Pelotas

Jeronimo Medina Madruga's LinkedIn account Jeronimo Medina Madruga's twitter account

Awesome tech events for

Priority access to all content

Video hallway track

Community chat

Exclusive promotions and giveaways