pIFthon

--Originally published at 101 For Tec

Check out the post I worked out with Merino

M E R I N O

If statement:

The If statement is a conditional statement and works like this. If a value is true then the instruction stop and the code continues, but if the value is false, the code read the next line on the IF.

loop_architecture.jpg

The syntaxis is like this:

if expression:
<body>
else:
<body>

Here is an example:

Captura de pantalla 2016-09-12 a la(s) 10.25.02.pngCaptura de pantalla 2016-09-12 a la(s) 10.25.28.png

For more details about IF and ELSE you can go to here and here. And also check this blog for more loops wohoo.

Ver la entrada original


Fruit-Loops

--Originally published at 101 For Tec

Loops are very used in daily life, and I´m not talking about food, i´m talking about programming. But you may ask what is a loop. A loop according to the Merriam Webster is “a series of instructions (as for a computer) that is repeated until a terminating condition is reached”.

Loops depend of a condition, this is a boolean, a boolean is a value that can be either false or true, for more information of Basic Operators, you can go here

In python we have two types of loops and one conditional:

  1. If else
  2. For
  3. While

Now…what is the structure of a loop? It is the following

loop-statement

And…what about the ‘if/else’ conditional? Is this

conditional

In the following posts Rodrigo Merino and I will explain you more about this

References:

http://www.merriam-webster.com/dictionary/loop

http://www.tutorialspoint.com/computer_programming/computer_programming_loops.htm

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


Wooo, this is more cool than Gandi Libraries

--Originally published at 101 For Tec

This is one of my shortest posts since this is more of self discover.

Libraries are a very useful topic, they are dictionaries that are already made and that you just invoke them, yep…invoke, you just say ‘import library_name’ and ready, you use it as normal.

Here is the link to all the libraries that python has:

https://docs.python.org/3/library/

 


*Insert your username*

--Originally published at 101 For Tec

How can I make inputs? Its Easy peasy dude.

Inputs themselves are a function and you only need to put ‘input()’ and the program will stop in this line and don´t continue without receiving a string input, this is text.

Here is an example:

input

Here is what happend

ans

 

 

References:

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

 


The return from the variables

--Originally published at 101 For Tec

Always in Jr High the most difficult thing for the majority of the people is algebra, find the x. Now in programming languages the variables are back, but we call them in Python basic types.

The amount of basic types differ between authors, in this blog we are going to consider five, why? because Anacleto said so, so don´t complain. The five data types are:

  1. Numbers

    • Integers ‘Int
    • Decimals ‘Float
    • Complex ‘Complexnumbers
  2. String

    A ‘String official definition is: “a contiguous set of characters represented in the quotation marks”. Some other information of Strings:

    • Python allows for either pairs of single or double quotes.
    • Subsets of strings can be taken using the slice operator ([ ] and [:] ) with indexes starting at 0 in the beginning of the string and working their way from -1 at the end.
    • The plus (+) sign is the string concatenation operator and the asterisk (*) is the repetition operator.
    • Here is one example:string0_1
    • Here is what is printed:
  3. List

    Python´s Lists are very similar to what C users know as Arrays, the advantage is that in Python the items inside a List, can be from different data types.

    • A list contains items separated by commas and enclosed within square brackets ([])
    • The values stored in a list can be accessed using the slice operator ([ ] and [:]) with indexes starting at 0 in the beginning of the list and working their way to end -1.
    • The plus (+) sign is the list concatenation operator, and the asterisk (*) is the repetition operator.
    • Here I have one example list0_1
    • Here is what shows when you run the program in Cygwin list0_2
  4. Tuple

    Tuples are lists not-editable or updatable, are kind of static lists. The difference is that instead of braces, they use

    list0_1
    list0_2
    dictionary
    Continue reading "The return from the variables"

Sensei? Is that you Sensei

--Originally published at 101 For Tec

Captura

Resultado de imagen para what meme

Yep, I know it seems like chinese but it´s more easy than it appears to. The Zen of Python are recommendations by a Pythoneer.

These are 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!

You see, they aren´t as difficult as their preview. This sentences were made with the purpose to help to the future Python programmers to make better, more beautiful, faster, and more understandable code. In my personal opinion the ones that I think are more important for the beginners are these:

  • Simple is better than complex.

As one genius person that I´ve never know once said, “keep it simple stupid”. This something crucial in the code of every programmer.

  • Readability counts.

You need to keep in mind that you´re not the only one that is going to read your code un real life so it needs to be understandable for everybody. Also, when in 10 years you open your code, you need to understand it ad be able to know what your intentions were

science
giphy (3)
Continue reading "Sensei? Is that you Sensei"

Jokes inside, don´t read

--Originally published at 101 For Tec

A lo largo de la historia de programación los comentarios han jugado un papel muy importante, siendo desde bromas hasta guías de para los futuros lectores del código.

Hacer un comentario en Python 3.5 es  verdaderamente sencillo

Tenemos dos opciones, comentarios de una sola línea y comentarios de múltiples líneas. Para la primera de las dos opciones solo necesitamos agregar un Hashtag ‘#’, si, es así de fácil

¿Y qué pasa con la otra opción? ¿Se ponen dos hashtag?
La única cosa que debes hacer es poner tres “apóstrofes” -”’-. I know, parecen las cejas de un gatito. So, cualquier pregunta, por favor ponla en los comentarios.

#TC101

Thanks to After Hours of Programming