How to Define and Modulated a Code in Python - #First steps in Python part 8
Today I learned a bit of Python, and how modulating your code can make your life so much easier and simple (as a programmer)
Basically, you can module your code, and that means that you can make multiple files contain different parts of the code (like the part were you define information or/and the part you process it) and just Define it as such, and import in the main code.
Defining a part of code is just making code "Compact" by defining a name to it, so here's an example:
def xtable(math)
for valor in range(1,10,1):
print(str(mult + " x " + str(value) + " = " + str((multvalue))
The code above is defining xtable the code below it, so every time I write xtable as a piece of code in my code it will produce the code below (which is a multiplication table from 1 to 10).
This doesn't just make the code shorter, it also makes changing it easier, since I can just modify the code 1 time (let's say to make a multiplication table go to 20) I just change the code below the def and all interactions of that code will also change.
and also I learned how to module my code, which is just:
from Directory.the_file import *
that imports def's from another file, so I can apply it in my main file, or the main module
The course I'm using (it's in Portuguese): https://on.fiap.com.br/local/salavirtual/conteudo-digital.php
If you have any question or suggestion on other topics, feel free to comment down below or ask me in Facebook or Instagram!
Visit my Facebook Page in: http://fb.com/teteusbionicoficial
Visit my Instagram: https://www.instagram.com/teteusbionic/
Visit my Website: http://www.teteusbionic.com.br