# OOPS! I DID IT AGAIN

--Originally published at Coding The Future

via GIPHY

Hello my fellow programmers! I'm back again with a new and interesting topic for today. And I know, I said I would stop with the song references, but I just can't!

Today, I'm quoting Britney and her masterpiece Oops! I did it again to get us started on the topic of recursion. Recursion is the repetition of an algorithm for as many times as necessary to generate a conclusion.

#### What is recursion?

Recursion is funny because it's kind of related to infinity. Is not the same as loop, because the function "calls itself more than one time within its own body"1, becoming something like a function inside a function, inside a function, inside a function, and so on. It can also be interpreted as solving a big problem in smaller and smaller portions, and solving the first and smallest, followed by the second, until reaching the final big problem. However, a recursive function must end at some point to successfully obtain an answer.

Let's dive deeper into the topic. To do that, we will explore a popular example.

#### Examples of recursion

The Fibonacci numbers are the numbers of the following sequence of integer values:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

The Fibonacci numbers are defined by:
Fn = Fn-1 + Fn-2 with F0 = 0 and F1 = 1.

If we wanted to write a function that returns a determined index of the of Fibonacci series we would use something like this:

```def fibo(n): if n == 0: return 0 elif n == 1: return 1 else: return fibo(n-1) + fibo(n-2)```

As you may notice, the else statement, which exits within fibo calls itself again, until the the if or the elif are reached. If Continue reading "OOPS! I DID IT AGAIN"

# ARE YOU A LIBRARY MOUSE?

--Originally published at Coding The Future

Hello everyone! Guess what? Partials are over! That means that today we're back on track... And today's topic is libraries, a.k.a. modules in Python.

Let's begin by defining modules. TutorialsPoint defines a module as a logical way to "organize your Python code. Grouping related code into a module makes the code easier to understand and use".1 In short, a module is a separate file where you define functions related to a specific action and then import it to your code. The best thing about it all is that it makes coding less confusing and functions re-usable across several programs!

Let's get started!

#### Creating a module

Creating a module is easy. All you have to do is create a new Python file and define the functions that will belong to that module.2 For example, if you wanted to create a module containing all the functions for Tic Tac Toe, you would create a module named tictactoe and define all the functions inside.

#### Using a module

Once you wanted to use the library you just created or downloaded from the internet, the first step would be to import it. In the file where you will use it, type the word import followed by the name of the module. Let's say we wanted to import the tictactoe.py module we imaginarily created above:

`import tictactoe`

That imports the module, but in order to use the functions inside it, you need to call the function by using the name of the module (dot) name of the function. Let's say I wanted to use the newGame function within the tictactoe module:

`tictactoe.newGame()`

That's it for today... I know, that was easy! Happy Mexican Independence Day! ??

@emamex98

--

1. Definition by TutorialsPoint

# Functions

--Originally published at Python Blog

The fuctions are used for make the progrma more efficient!

This Structure:

def  Name_of_Function(N,A):

process

return Variable

And for Calling

Var= Name_of_Function(N,A)

# Functions in python

--Originally published at Hackerman&#039;s house

A function is a structuring element that groups some lanes of code that can be utilized many times in the program. Is basically defining a formula to then just put the name of the formula, and the program will run it without the need of writing it again.

The syntax looks like this.

def name-of-the-function(Parameters):

Statements

The statements determine what your function will do.

To call a function you just need to put the name of a function previously defined.

name-of-the-function()

This is a really simple example about how to define a function and then call it two times. What this would do is run the same function two times. It is important to note that this function has no parameters.

And this is how the program works.

Besides this really simple program I created another that actually uses parameters.

This program executes a sum of the two parameters given.

And here it is how it works.

# FOR ALL THOSE PROCRASTINATORS

--Originally published at Coding The Future

If you are reading this right now, you were probably procrastinating, and just started studying for tomorrow's test, right?

Well, as always, I've got you covered. Here's a quick video summary of what you need to know for the first partial. I hope things are not too strange.

Good luck!

# Funciones()

--Originally published at Eduardo&#039;s Projectz

Introducción Básica a las Funciones:

Antes que nada tienes que conocer qué son las funciones: Una función es una forma de agrupar algoritmos que realicen determinadas acciones, pero que estas se ejecuten solamente cuando la función es llamada. Más sencillo aún, poner un algoritmo dentro de una función y, al correr el programa, no se ejecutará el algoritmo dentro de la función si no se ha hecho referencia a la función que contiene el algoritmo.

¿Cómo definir una función?:

Para definir una función solo basta con escribir “def” seguido del nombre de la función , en este caso “funcion”, seguido por paréntesis “()” y dos puntos “:”.

¿Qué hacer dentro de una función?:

Una vez definida la función, se puede escribir cualquier algoritmo dentro de ella. Teniendo siempre cuidado con los espacios ya que estos son los que limitan la función.

NOTA: Una función puede contener cualquier tipo de algoritmo y cualquier cantidad de ellos. No obstante, una buena utilización de las funciones implica que estas solo deben contener una única acción repetible.

¿Cómo llamar una función?:

Para llamar una función simplemente escribe el nombre de la función seguido de paréntesis, en este caso “funcion()”

# Calling & Creating Functions

--Originally published at Py(t)hon

I think is time to start with functions, i’m no experts at this topic so maybe we can learn together, let’s go

First, what is a function? Very simple, is a piece of reusable code that can be call upon whenever you need it. In other words, if you are going to repeat a code several time the best you can do is create a function, so you don’t have to write it all over again and again. Is to make your life easier.

To create a function you have to start with def follow by parenthesis (), inside this parenthesis goes the parameters necessary, if needed of course, after the parenthesis goes a colon (:) and then to close it, use the return function follow by the value statement, if you don’t want it to return anything, just leave a blank space, the system will take it like None.

Here is my example:

In this example I can call whenever I want the areacuadro function, that will be all:) #Pug#Tec#TC101#Functions

Here is a webpage where you can find it better explain link

# LET’S MAKE COOKIES! An intro to Functions

--Originally published at Coding The Future

When I think of functions in any programming languages, I think of them as the reusable tools you use when baking cookies, for example. Here's why...

Every time you make cookies, you don't buy a new bowl, a new mixer, a new oven, and a new tray, or do you? If you do, you're just... something else. However, must of us reuse the same materials. There's obviously the ingredients that are single-use only, but most of the stuff can be reused and that is a good thing, because that way there's no need to buy a new tray every time we want to bake cookies.

Translating this into programming, if we are going to be using the same code several times, there's no point in writing it several times. It only makes sense to write it once, and use it (or call it as many times as we need to.

So basically, a function is "a block of organized, reusable code that is used to perform a single, related action" 1 that improves the efficiency and speed of your code. Remember that less lines of code means also better readability.

#### Defining a Function

When defining a function, start by typing the keyword def (I'm guessing it's short for define), followed by a unique name for the function, and then include brackets where any input parameters will also be declared (think of input parameters as the single-use ingredients that can change depending on what you want to achieve). Close the line with a colon.

In the following lines, which are always indented, is where the magic happens. You can include a explanation what the function does in the first line in quotation marks, although this is optional. This will not affect your function, and is often referred Continue reading "LET’S MAKE COOKIES! An intro to Functions"