Lo que pasa de vez en cuando

--Originally published at 101 For Tec

Hoy sucedió algo muy gracioso cuando intentaba entrar a un sitio web, el archivo no fue encontrado, pero…no salía la típica ventana que dice Error y un código que los mortales no entienden, sino que los diseñadores se molestaron en hacer una página para casos como esos. El link es: http://www.ibiblio.org/obp/thinkCSpy/chap11.htm#5

¿Qué tiene eso de interesante? todos lo idiomas que ponen y los dialectos

Echa un vistazo….

0 1 2 3 4 5 6 7 8

 

Referencias:

http://www.ibiblio.org/obp/thinkCSpy/chap11.htm#5


Jisho para tu, jisho para mua

--Originally published at 101 For Tec

Jisho 辞書, es la palabra japonesa para diccionario tranquilos, hoy no hablaré de cosas otakus…Hoy vengo a hablarles de los diccionarios en Python.

Un diccionario es similar a lo que en Java llamamos array, la diferencia radica en que podemos personalizar las keys  que son las posiciones, es decir los nombres de las keys no están limitadas a números, sino que puedes personalizarlas y ponerles el nombre que desees.

La segunda cosa son los niveles, no hay límite, es decir que puedes seguir y seguir guardando información en una key; ahora, ¿qué puedo guardar en una key? Puedes guardar lo que desees, inclusive objetos.

Ahora el formato, los diccionarios se ponen entre llaves ‘{}’ y para una posición específica de un diccionario se pone nombre[posición]

Aquí hay un ejemplo que Angel compartió en su blog

dictionary

Referencias:

http://www.tutorialspoint.com/python3/python_variable_types.htmhttps://angelmendozas.wordpress.com/2016/08/30/python-basic-types/


No, no es el de mate

--Originally published at 101 For Tec

Rangos, ¿qué es eso? Eso no es queso, es una función que crea sucesiones aritméticas. Así es como luce

range(m, n, k)

m es el punto de inicio

 es el límite superior, nunca se toca

es el espacio entre cada número

ahora que sabemos que es un rango ¿en qué se usa? la mayoría de veces se usa como interator en loops, sin embargo tiene mas aplicaciones dependiendo de lo que estés realizando

He aquí un ejemplo

ejemplo.PNG

Referencias:

http://pythoncentral.io/pythons-range-function-explained/

https://geekytheory.com/la-funcion-range-en-python


I can read your mind

--Originally published at 101 For Tec

Reading files sounds very complicated, but is very easy an this GIF explains it very well

Reading-Text-File-Animation-s

And…what about if I want to make a list out of a bunch of words separated by a comma or semi-colon, well we have a GIF for explaining this, here you will use the split() method.

Reading-CSV-File-Animation-s

Here we have an example from our friends of 101Computing

The code below realizes 5 main steps:

  1. Step 1: Open the text file using the open() function. This function takes two parameters: The name of the file (e.g. “playlist.txt”) and the access mode. In our case we are opening the file in read-only mode: “r”.
  2. Read through the file one line at a time using a for loop.
  3. Split the line into an array. This is because in this file each value is separated with a semi-column. By splitting the line we can then easily access each value (field) individually.
  4. Output the content of each field using the print method.
  5. Once the for loop is completed, close the file using the close() method.

https://www.trinket.io/embed/python/2d1f14806c

Here we have the “modes” available for open() 

Mode Description
r Opens a file in read only mode. This is the default mode.
r+ Opens a file for both reading and writing.
w Opens a file for writing only. Overwrites the file if the file exists. If the file does not exist yet, it will create the new file for writing.
w+ Opens a file for both writing and reading. Overwrites the file if the file exists. If the file does not exist yet, it will create the new file for writing.
a Opens a file for appending. The file pointer is at the end of the file. So new data will be added at the end of the file.
Continue reading "I can read your mind"

You wanna try?

--Originally published at 101 For Tec

“Any program input such as a user typing at a keyboard or a network connection – can potentially be the source of security vulnerabilities and disastrous bugs. All input should be treated as potentially dangerous.

Determined attackers can use carefully crafted input to cause programs to run unauthorized commands. This technique can be used to delete or damage data, run malicious programs, or obtain sensitive information.”

This is the reason we need to validate the inputs we include in a program, so that when we “try” to do something we “catch” the errors, exceptions etc. For this we literally use the commands try and catch. Here is one example

https://www.trinket.io/embed/python/50ed4f51fd

Also, we need to be careful using this and be sharp enough for catching all the possible exceptions so that it is very difficult to find a “whole” in our code.

References:

Python Tip: Validating user input as number (Integer)

http://cis1.towson.edu/~cssecinj/modules/cs0/cs0-input-validation-python/


Videos for relaxing

--Originally published at 101 For Tec

Most of the time, we manage very high stress levels, and we need to relax, here I show you some helps

Watch series

bimages.png

Series help you to relax and concentrate in other things

Watch something new, not just the classy

This really helps a lot, because you make yourself more open and know more about other cultures, I, for example, am starting to see korean doramas

45d7f1ccf1ee5adaf0160b2c12e63a1e.jpg

Surf in the Web

God, web is a really big ocean that is recomendable for you in stress moments, and it has from everything, not just procrastinating stuff also you can go into sites like Lynda or Coursera and learn new stuff

14682235441.jpg


What´s list?

--Originally published at 101 For Tec

Today I´m talking about lists, as I mention in a previous post, a list is a group of items that have a position. The syntax of the lists is like it follows:

name_of_the_list = [elements,elements]

The positions start at 0 and you call them like this

name_of_the_list [0]

Also you can modify them just calling the position and making it equal to the new value

list1[0]:  physics

or delete elements writing del before the position

del list1[2];

Also you´re able to do the basic operations

Python Expression Results Description
len([1, 2, 3]) 3 Length
[1, 2, 3] + [4, 5, 6] [1, 2, 3, 4, 5, 6] Concatenation
[‘Hi!’] * 4 [‘Hi!’, ‘Hi!’, ‘Hi!’, ‘Hi!’] Repetition
3 in [1, 2, 3] True Membership
for x in [1, 2, 3]: print x, 1 2 3 Iteration

or for more fun stuff check this:

https://www.tutorialspoint.com/python/python_lists.htm


I know that you know that I love you

--Originally published at 101 For Tec

Have you ever heard something like this? Well, in natural language is something common, and oh surprise, in programming also is. In programming we have something that is called recursive functions.

“Recursion is a method of programming or coding a problem, in which a function calls itself one or more times in its body. Usually, it is returning the return value of this function call. If a function definition satisfies the condition of recursion, we call this function a recursive function.

A recursive function has to fulfill an important condition to be used in a program: it has to terminate. A recursive function terminates, if with every recursive call the solution of the problem is downsized and moves towards a base case. A base case is a case, where the problem can be solved without further recursion. A recursion can end up in an infinite loop, if the base case is not met in the calls.”

Here is one example

This code throws the six first lines of the Pascal´s triangle:

pascal.PNG

References:

http://www.python-course.eu/python3_recursive_functions.php


So…you´re into this?

--Originally published at 101 For Tec

Nested loops ¿what are they? A nested loop is a loop within a loop, an inner loop within the body of an outer one. Is possible to realize this with all the different types of loops, with for´s, here is the basic structure:
nested_for_syntax

also with while’s

nested_while_syntax

with if else, and also combining them.

Here is one example of what you can do with nested loops:

nested.PNG

References:

https://www.tutorialspoint.com/python3/python_nested_loops.htm

http://tldp.org/LDP/abs/html/nestedloops.html