Tag Archives: #f9f9f9

#mastery08 Python conventions (Zen of Python)

The zen of python is, according to long time Pythoneer Tim Peters, a set of rules you have to follow or at least to take into account while coding in python which are:

Source: https://www.python.org/dev/peps/pep-0020/

08 

1014

Gilberto Rogel García

Mastery 19

¿Como hacer un while?

Ejemplo 1:

El contador Indica que hasta que este llegue a el total de 10 entonces se detendrá y ya no se realizará el código contenido dentro de la sentencia while , de lo contrario mientras el “contador” sea menor a 10 entonces el código contenido se ejecutará desplegando hasta 10 veces “Hola Mundo” en pantalla.

19 1017

Mastery 15

Las sentencias de decisión o también llamadas de CONTROL DE FLUJO son estructuras de control que realizan una pregunta la cual retorna verdadero o falso (evalúa una condicion) y selecciona la siguiente instrucción a ejecutar dependiendo la respuesta o resultado.

¿como se usa un if?

un if sigue el siguiente codigo

este codigo utiliza una condicion que va secuenciada con punto y coma

If(Inicial;Condición;Aumento)

15 1017

Python conventions (Zen of Python)

                                                                                                                       @PablO_CVi

 Many years ago a Pythoneer Tim Peters succinctly channels the BDFL’s guiding principles for Python’s design into 20 aphorisms, only 19 of which have been written down.      

        “Beautiful is better than ugly.    

        Explicit is better than implicit.    

        Simple is better than complex.    

        Complex is better than complicated.    

        Flat is better than nested.    

        Sparse is better than dense.    

        Readability counts.    

        Special cases aren’t special enough to break the rules.    

        Although practicality beats purity.    

        Errors should never pass silently.    

        Unless explicitly silenced.    

        In the face of ambiguity, refuse the temptation to guess.    

        There should be one– and preferably only one –obvious way to do it.    

        Although that way may not be obvious at first unless you’re Dutch.    

        Now is better than never.     Although never is often better than *right* now.    

        If the implementation is hard to explain, it’s a bad idea.    

        If the implementation is easy to explain, it may be a good idea.     

        Namespaces are one honking great idea — let’s do more of those!”(2004, p1).

Recuperado de: https://www.python.org/dev/peps/pep-0020/

 

 

The Zen of Python

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren’t special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one– and preferably only one –obvious way to do it.
Although that way may not be obvious at first unless you’re Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea — let’s do more of those!

—Tim Peters

This series of apparently senseless phrases are what Tim Peters considered the Zen of Python. For me it was quite hard to understand at the beggining, but then I found this page which helped me a lot to understand what this Zen was about. 

They depict in weird poetic way the customs that one should follow when coding, in this case in Python but most of them apply to any programming language, so that your code is not only efficient, but also easy to read and understand by even other people beside you. 

And well the page that I have posted above gives some good examples to the phrases that are stated in the Zen of python. But if you don’t want to look to an example of every line well I will give you a summary. 

When we say that beautifull is better than ugly is a sugestion as to ident the program, no more horrible one long lines that means too much to understand them. Whenever we do, call or whatever something we should show clearly what we have done, so there are the less amount of guesses about our code there can be.

Whenever you have to choose between a bunch of easy code that just screws people’s minds you better choose some complicated but yet fewer functions or chunks of code that can help one follow the thread of your code. And of course avoid those long chains of nested loops or conditionals, they just scream: skip me!!

The other thing that we have to take care of is about making our code too complex just for especial cases, many times we can just point at them by treating errors instead of making our code very difficult to comprehend; trying to not sacrifice too much of its functionality in the process. 

We should always try to solve the things the simpliest way we can, a way to figure out if we are doing it right is trying to explain what we have done, if we can’t; then we have a problem. 

And for last I don’t know if I have got it right, but I guess it’s abaout using variables to store the values of large statements, and use appropiate names for them, not names that don’t have much sense or even you can’t remmember.

This is my of my

Babylonian Method

Long time Pythoneer Tim Peters succinctly channels the BDFL's guiding principles for Python's design into 20 aphorisms, only 19 of which have been written down.