Validating User Input in Python

--Originally published at Ed_Alita


User do not know how to use a computer

This mentally you need to have in order to have a great code.

Lets see if I have the next code:


If the user gave you for any reason a letter because he or she is stupid the code will crash:


In order to prevent this we are going to validate what the user gave us is corect in this case first we are going to obtain the input without any type we do this by puting raw_input.

the next thing is to do the text if it is a number with int(User_Input). since we know that if this obtain a number it will crash we are going to do a cheat to stop this.

We use Try and except:

What try does it proves the code and Except will do an action if the codecrash.

The complete code will look like this:


In this case if the user gave us a string it should make this:


If the user gave us a integer it should run smothly:


Go and Have fun as a Code Master

Use of Range in Pytho

--Originally published at Ed_Alita

Don’t be scared by the word there are easy as pie

Let’s see that you want to print all number between 1 and 5; therefore you need a range. But let me tall you a little secret in range it only takes until the number you tell it but do not  take the actual number in consideration. Let’s see an example:

range1 In this the 5 willnot be printed.

The actual result of this code is the next one:


Now lets see a more complex range with two variables:


in this case the result will be:


If you want to see more info in the next link:

Reading and writing of text files

--Originally published at Ed_Alita


Computers do even read and write?

YES, they do.

Calm down it is not wichcraft.

Lets see how to do it.

Firts we need to create a .txt file and we do this by typing file = open(“file name”, “action”)

The actions that you can do are the next ones:

  • “w” this is use to write in a .txt file
  • “r” this is use to read
  • “a” open the file for apending

The action that we are going to do is to write so we put file.wite(“Hello”)

The code should look like this.


Now in other to see this we need to open it again and put print(


The result of the code is the next one:


Use of recursion for repetitive algorithms in Python

--Originally published at Ed_Alita

The term recurssion is simple it means the use of a repetive funtion inside the funtion. Let’s see if we want to do the factorial funtion we are going to encounter to case the case of factorial 0 and the other cases. Having this in mind we have to make these two in code.

Therefore the code is the next one:


The result is the next one:


This is easy only having in mind that we are having ti use the same funtion between the repetitive one.

You can check these link for more information.

(“Tuplas”, “TC”, 101)

--Originally published at Eduardo's Projectz

En la programación, así como en la vida real, es muy probable que se describa un objeto como un agrupamiento de datos distintos. Esto son las “Tuplas”.

Para declarar una tupla es tan simple como asignar a una variable valores encerrados en paréntesis.

a = (1, “a”, 2.5)

Un ejemplo de esto puede ser una fecha, en donde se necesitan tres elementos; día, mes y año.

Por lo que podemos decir:


Al igual que en las listas, los datos en las tuplas tienen asignados un orden, por lo que en este caso el día de cumpleaños (2) está asignado a la posición 0; el mes (“septiembre”), a la posición 1 y el año (1998) a la posición 2.

A diferencia de las listas, las tuplas no pueden ser modificadas.

También es posible asignar muchos valores a una variable separados por comas y esto crearía una tupla.


Para más información en este tema visita:

Para un video explicativo sobre el tema:



Métodos para listas

--Originally published at Eduardo's Projectz

Dentro de las listas existen varios métodos y funciones que se utilizan para obtener un mayor beneficio de estas.

Las principales funciones son:


Se utiliza para conocer la longitud total de una lista.

Para utilizarse, simplemente se escribe “len” y entre paréntesis el nombre de la lista que deseas.


Nótese que esto te da la longitud, no la última posición que sería, en este caso, el 2.


Se utiliza para añadir un valor al final de una lista, este valor tiene que ser del mismo tipo de dato que la lista.

Para utilizarse, escribe el nombre de la lista seguido por “.append” y, entre paréntesis, el valor que deseas añadir.




Este método permite añadir un valor a la lista en una poción determinada.

Para utilizarse, escribe el nombre de la lista seguido por “.insert” y, entre paréntesis, la posición en donde deseas poner un valor seguido de el valor, separados por una coma.




Esto se utiliza para quitar un valor existente en una lista.

Para utilizarse, se escribe el nombre de la lista seguido por “.remove” y el valor que se desea remover entre paréntesis.




Esto se utiliza para conocer en que posición se encuentra un determinado valor.

Para utilizarse, se escribe el nombre de la lista seguido por “.index” y el valor que se desea conocer entre paréntesis.





Para más información en el tema, visita:

O si prefieres un video:


While vs For in Python

--Originally published at Ed_Alita

The backgroud

This two funtions are used to create loop that inside is a code that you wish to repeat it self. The question is if they are the same how to choose between them. I will explain each one and then teach you how to choose between them.


This funtion repeats itself only the times that you indicate or until it condition is not longer true.

Lets see this example:


This code for each letter in the word Python will run the code.

Let’s see what it does.



This funtion repeats itself until it make false it’s value.

This is the logic that While follows:


The next Example will make it clear:


This program will run each time until count be 9. Lets see what it does:


Which one I use?

The use of each one depends on what you need. Lets see if you know how many times the user will put the correct answer use for but if you don’t know how many times you can use a infinite while.

The material use can be seen here:


Nesting Condicionals in Python

--Originally published at Ed_Alita

Did you mean this?


Nesting is puting a lot of conditional in order to make a more complex decison. For example the joysticks of a Xbox 360 have this kind of thinking.
Lets see a example of a code to see it clear:
The nested of this conditional take the input and comparte it with a range of cases.
This kind of of coding make us a easy liofe because it make the code to has flow and make it simple to see it.
The Result of this code is the next one:

Nesting of conditional statements

--Originally published at Py(t)hon

You may think there is no more you must know of the conditional statement, well… You are wrong, there is another knowledge call nesting that must master. Perhaps you didn’t know that in a nested if construct, you can have an if…elif…else construct inside another if…elif…else construct.

There may be a situation when you want to check for another condition after a condition resolves to true, this is what is call nesting, a conditional inside another conditional.

Here is an example:


Here is a youtube video:

That’s all #Pug #Nesting #If #Python #ISC #Tec #TC101


If, else and elif Python

--Originally published at Ed_Alita

The core of a program is if and else because thaey give the flow to a program therefore in order to make a program you net to know how do if and else work.





@SummerBreak chill flow summerbreak summer break





To put in python this is the rules to put it:


It has three parts the comparator and then the action this is a if context.

To do a else if comparation is the next one.


The last part is the else if the compartor does not apply it goes directly to the else.

If the condition is true:


if the cpondition is false:

Now you are a step futher in becoming a code master.


This operator is use to compare a variable to a lot of expressin if any of them is true you go to a default expression.

Put the next cod eto invoque the elif:


the result is the next one:



The material seen here is in: