Python Projects : FUNctions ()

Hello World,
 The last post I did was about creating a simple While Loop, and how that has helped me tremendously with having my programs run a bit smoother, with cleaner code. Well the same can be said of functions, they come in very handy, especially for repeating situations. I found that the combination of that simple While Loop + a simple Function is quite helpful.


Python makes it SUPER simple to create, define and call a function.
Here is a quick example.

# Defining the function
def new_function():
       print("This is  a working function")
# Calling the function
new_function()


That's it, its very simple to do, and I use this method a lot to make sure that my logic is working, especially if there will be multiple things happening. This is a great way to keep things organized, and to keep your code clean. Its also a great way to make corrections or upgrades in only one place, especially if the function is called or used in multiple places.

Keep in mind, these functions can do anything, so they can be as complex as you want them to be.
Functions will be your friends, and Python makes it really easy for you to create them, so do your best to utilize them, it will make your life a lot easier, and your programs more organized.
Enjoy.


Remember:
"Coding is the closest thing we have to a superpower" - anonymous
Go be a Super
-ash



Comments

Popular posts from this blog

No more controllers for playing games

Look out iPhone, the G1 is coming. sw33t.