- Python Projects for Kids
- Jessica Ingrassellino
- 300字
- 2021-07-09 19:35:14
Finding a remainder – modulo
Modulo can seem like a strange concept. In fact, unless you are a programmer, it is likely that you have never heard of modulo. Modulo is a mathematical function that allows us to do a pision problem but only return the remainder. Why is this even useful? Why is it a good idea, and why should we care?
Usually, we want to know the entire answer to a pision problem—the quotient and the remainder. There are times, though, when we will only want to know the remainder of the pision problem. We will only care about what is leftover. Modulo is like a monster eating our dessert: we give the monster numbers to pide, and it just gives us leftovers.
While modulo is not especially useful in the world of school arithmetic, it can be very useful in moving objects in a game. So, it is good for us to build a modulo function and learn how modulo works.
To build a modulo function, you will need to get user input, just like all of the other functions you made. Then, you will call the modulo function. The symbol for modulo is %
You can place the modulo operator where you would normally place the pision sign. Copy the following code in your Python shell as an example:
def modulo(): first = int(raw_input('What is your first number?')) second = int(raw_input('What is your second number?')) print(first % second)

In the preceding screenshot, you can see how we added the modulo function to the other functions. If you still find modulo confusing, don't worry right away. Just know that it might come up as you are designing games, and you can check back here, as well as do an Internet, search to better understand modulo.
- 軟件項(xiàng)目估算
- JavaScript全程指南
- Building a Recommendation Engine with Scala
- 精通Scrapy網(wǎng)絡(luò)爬蟲
- 深度學(xué)習(xí):算法入門與Keras編程實(shí)踐
- 飛槳PaddlePaddle深度學(xué)習(xí)實(shí)戰(zhàn)
- ASP.NET程序設(shè)計(jì)教程
- Vue.js 2 Web Development Projects
- .NET 4.5 Parallel Extensions Cookbook
- 代替VBA!用Python輕松實(shí)現(xiàn)Excel編程
- FPGA嵌入式項(xiàng)目開發(fā)實(shí)戰(zhàn)
- Arduino可穿戴設(shè)備開發(fā)
- Hack與HHVM權(quán)威指南
- JavaScript前端開發(fā)基礎(chǔ)教程
- Koa與Node.js開發(fā)實(shí)戰(zhàn)