When in doubt, go back to yourself.

--Originally published at Just A Turtle Coding.

So recursion is a useful resource in Python. It will save you lots of lines of code, bytes of memory and lots of time. Here’s how you do it:

To use this technique, you just have to include the same function you’re defining in the same function. An example is represented here:

The factorial function is recurring by definition but here’s an example of what or how it’s done. For more info, check out this post:

When in doubt, go back to yourself.

--Originally published at Just A Turtle Coding.

So recursion is a useful resource in Python. It will save you lots of lines of code, bytes of memory and lots of time. Here’s how you do it:

To use this technique, you just have to include the same function you’re defining in the same function. An example is represented here:

The factorial function is recurring by definition but here’s an example of what or how it’s done. For more info, check out this post:

Factorials again!

--Originally published at Just A Turtle Coding.

So here’s another use of the for loop, you can use it to calculate the factorial of a number.

First you have to declare your variable which will be storing the count, and the one which will be storing the total. After that you just multiply and add inside the for loop.

Another example done by turtle :D

Factorials again!

--Originally published at Just A Turtle Coding.

So here’s another use of the for loop, you can use it to calculate the factorial of a number.

First you have to declare your variable which will be storing the count, and the one which will be storing the total. After that you just multiply and add inside the for loop.

Another example done by turtle :D

Multiplying Stuff

--Originally published at Just A Turtle Coding.

A quick tutorial on how to make the factorial function using a while loop.

First you have to state a counting variable for it to go through the while loop, you also have to declare a variable where the total will be stored.

Then it’s just a piece of cake, you have to multiply the variable where the total is being stored. Important note, the variable with the total can’t be 0, it has to start at 1 for it to be multipliable.

Multiplying Stuff

--Originally published at Just A Turtle Coding.

A quick tutorial on how to make the factorial function using a while loop.

First you have to state a counting variable for it to go through the while loop, you also have to declare a variable where the total will be stored.

Then it’s just a piece of cake, you have to multiply the variable where the total is being stored. Important note, the variable with the total can’t be 0, it has to start at 1 for it to be multipliable.

Using Elif

--Originally published at Just A Turtle Coding.

Owner taught something about ifs and elses but what’s the difference between an else and an elif?

It’s easy, an elif statement has no limit as to how many of them you can put without indenting them.

For example, the elif compares something when the condition wasn’t met but there’s another condition to check.

This is only a simple post but I hope it clarified some doubts.

Using Elif

--Originally published at Just A Turtle Coding.

Owner taught something about ifs and elses but what’s the difference between an else and an elif?

It’s easy, an elif statement has no limit as to how many of them you can put without indenting them.

For example, the elif compares something when the condition wasn’t met but there’s another condition to check.

This is only a simple post but I hope it clarified some doubts.

def Yourself():

--Originally published at Just A Turtle Coding.

Python has lots of useful features like importing libraries or using pre-created stuff but what if you wanna create something completely new?

Python gives us the option of defining new functions and telling them what to do. It’s easy as 1.. 2… 3…

When using “def” in Python, you’re basically telling it that you’ll input a new function, something completely new. Or you could just change the name of a function or do whatever you want with Python.

Creating a function helps you to save time when you’ll be doing the same thing one time after the other one.

def Yourself():

--Originally published at Just A Turtle Coding.

Python has lots of useful features like importing libraries or using pre-created stuff but what if you wanna create something completely new?

Python gives us the option of defining new functions and telling them what to do. It’s easy as 1.. 2… 3…

When using “def” in Python, you’re basically telling it that you’ll input a new function, something completely new. Or you could just change the name of a function or do whatever you want with Python.

Creating a function helps you to save time when you’ll be doing the same thing one time after the other one.