# EASY AS 1,2,3?

--Originally published at Coding The Future

Image by Austris Augustus

Greetings everyone! And welcome to my last mastery article. To be honest, I thought I was done, but I just noticed I was missing an important concept in Python: ranges.

Ranges in Python are quite peculiar, because they work a little differently from other languages and also a little differently from what we're used to in Math class. Let's get right into it.

#### Declaring Ranges

Ranges can be used when we need to work with a set number of elements, like running a loop for a determined range.

To declare a range, we simply call the range( ) function, like in the following example:

`range(7)`

In this example, where only one number is included, Python asumes that your range will begin at zero, and end in 7. This range has seven elements, and it starts at zero. So if I printed a counter for the range, it would return 0,1,2,3,4,5,6.

However, things get a little tricky when we add a second number to the function, like this:

`range(1,7)`

In this example, I am working with a range from 1 to 7, but in Python this means from 1 to 6. The first number indicates where the range starts, but the second number represents the number after the last number in the range. So once again, if I were to print a counter, I would get 1,2,3,4,5,6. See? The seven is not included, and even though there is mathematically seven numbers between 1 and 7, the range only has six.

#### Using Ranges

We can use ranges for a variety of things, but the most common use is for loops. Here's an example of a for loop that prints Hello #n 5 times:

```for n in range(1,6): print("Hello #" + n)```

If we run this loop, it would Continue reading "EASY AS 1,2,3?"

# Loops, loops, loops …

--Originally published at Py(t)hon

Is time for us to learn about loops, the loops help us to repeat a piece of code several times instead of writing the code all over again. There are two kinds a while loop and a for loop, the while loop  tests the condition before executing the loop body, while a given condition is TRUE, it will repeat a statement or a group of statements. On the other hand, we have the for loop that executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.

Here is an example of for loop:

and for while loop:

That will be all here is a video for better understanding:

#Pug#TC101#Tec#ISC#Loops#While#For

# TEACH ME HOW TO BOT – Building a simple Twitter Bot

--Originally published at Coding The Future

Greetings everyone! I am back, and although this is long overdue, it's finally here!

Today I am releasing my tutorial on how to build a simple Twitter Bot. I have been working on a bot called Manny's Fortune Ball, a simple bot that replies with future predictions every time you ask it a question. You can go check it out by visiting its Twitter profile, and asking him a question. Its handle is @askemanuel.

Above I have attached a interactive slideshow. To move on to the next slide, just click on it, or tap the arrows.

Finally, this is the link to the GitHub repository so that you can check my source code: https://github.com/emamex98/TwitterFortuneBall

I hope you enjoy the tutorial! If you have any questions, do not hesitate to contact me:
Email: em (at) nuel.xyz

# Repetition

--Originally published at Python

In this post I will be talking about repetition in Python 3 and when you should use which type of repetition. As we already know (or should) the 2 types of repetition we have are “while” and “for”. They are different but follow the same idea, a process is repeated depending on what you want to achieve.

While is better used when you don’t know the number of times a process will be repeated. That’s why you just state a condition and expect it to be false at some point in time, that’s when it will stop and you will get your result from it.

For is used when you have a List or a Tuple. We know how many times a process will be repeated because we know the number of variables inside of the list or tuple used. So the final answer here will depend on the number of variables you have stored, not on a condition given to the program.

In conclusion, use While when you want a loop to repeat infinitely until a certain condition is false, use For when you have a list or a Tuple and you want a process to be repeated according to the number of variables you have in them and their value. If you want another explanation and easy to follow examples, click here.

# WHILE waiting FOR a new entry

--Originally published at Monty Python and the Blogging Tale

So, this is really easy to understand; when to use a WHILE loop and when to use a FOR loop. So it basically breaks down to what you know and what you do not know; if you do not know the extension or range of your data structure, then use a while; like for example, when you ask the user for an integer, you really do not know if the user is going to give you a number, so you create a while loop that repeats itself until the users gives you an integer:

But if you actually know the extension of your data structure (it could be a list, or a tuple), use a for:

As simple as that.

# Mientras tanto…

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

La herramienta de “while” es una de las más importantes y utilizadas en la mayoría de los lenguajes de programación. Esta permite que se repita un ciclo mientras una condición sea verdadera, y salga de este en cuanto la condición sea falsa.

Para establecer un “while” se necesita escribir la palabra while seguido de la condición que se deseé establecer y, al último, dos puntos.

En este caso, el código establecido para este “while” se correrá siempre y cuando la variable “x” sea menor que 10.

El código designado para un “while” debe de estar abajo de este con cuatro espacios de diferencia respecto a la posición del “while”:

En caso de que “x” sea menor que 10, se le añadirá 1 a el valor de “x”. Esto continuará sucediendo hasta que el valor de “x” ya no sea menor de 10. En caso de que el valor de “x” nunca fuese menor de 10, el código del “while” nunca se ejecutaría.

Aquí un ejemplo de un pequeño programa utilizando “while”:

Este programa te dirá cuantas semanas faltan para que consigas el dinero suficiente para algo.

Aquí un ejemplo de como funciona:

Para más información a cerca de “while” y otros bucles: https://geekytheory.com/bucles-en-python/ https://www.tutorialspoint.com/python/python_while_loop.htm https://docs.python.org/3/tutorial/controlflow.html http://www.mclibre.org/consultar/python/lecciones/python_while.html

Si te es más fácil seguir un video-tutorial: https://youtu.be/D0Nb2Fs3Q8c https://youtu.be/XkDOJC4hpw0

# Mientras tanto…

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

La herramienta de “while” es una de las más importantes y utilizadas en la mayoría de los lenguajes de programación. Esta permite que se repita un ciclo mientras una condición sea verdadera, y salga de este en cuanto la condición sea falsa.

Para establecer un “while” se necesita escribir la palabra while seguido de la condición que se deseé establecer y, al último, dos puntos.

En este caso, el código establecido para este “while” se correrá siempre y cuando la variable “x” sea menor que 10.

El código designado para un “while” debe de estar abajo de este con cuatro espacios de diferencia respecto a la posición del “while”:

En caso de que “x” sea menor que 10, se le añadirá 1 a el valor de “x”. Esto continuará sucediendo hasta que el valor de “x” ya no sea menor de 10. En caso de que el valor de “x” nunca fuese menor de 10, el código del “while” nunca se ejecutaría.

Aquí un ejemplo de un pequeño programa utilizando “while”:

Este programa te dirá cuantas semanas faltan para que consigas el dinero suficiente para algo.

Aquí un ejemplo de como funciona:

Para más información a cerca de “while” y otros bucles: https://geekytheory.com/bucles-en-python/ https://www.tutorialspoint.com/python/python_while_loop.htm https://docs.python.org/3/tutorial/controlflow.html http://www.mclibre.org/consultar/python/lecciones/python_while.html

Si te es más fácil seguir un video-tutorial: https://youtu.be/D0Nb2Fs3Q8c https://youtu.be/XkDOJC4hpw0

# 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!