Calling functions

--Originally published at Start in the world of the #TC101

In the context of programming, a function is a named sequence of statements that performs a computation. When you define a function, you specify the name and the sequence of statements. Later, you can “call” the function by name. We have already seen one example of a function call:

>>> type(32)
<type 'int'>

The name of the function is type. The expression in parentheses is called the argument of the function. The result, for this function, is the type of the argument.

It is common to say that a function “takes” an argument and “returns” a result. The result is called the return value


Zen of Python

--Originally published at Start in the world of the #TC101

™Tim Peters en el 2004 descubrió la manera perfecta de poder escribir en Python, y sobretodo nos demuestra que puede escribirse en cualquier idioma y esto te ayuda a hacerlo de una forma clara y fácil de entender y comprender el programa.

™Para que se desplieguen estas, tu únicamente debes de escribir “import this” y la magia esta hecha.

z

Leer más en:

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

http://emnl.me/python-sensei-the-zen-of-python/#more-37069


Use of loops with “while” and loops with “for”

--Originally published at Start in the world of the #TC101

Loops in Think Python

Loops with “for”

Python provides a clean iteration syntax. Note the colon and indentation.

Example

>> for i in range(0, 3):
>>     print(i*2)
0
2
4

Loops with “while”

A While loop permits code to execute repeatedly until a certain condition is met. This is useful if the number of iterations required to complete a task is unknown prior to flow entering the loop.

Syntax

while condition:
    //do something
>> looping_needed = True
>>
>> while looping_needed:
>>     # some operation on data
>>     if condition:
>>          looping_needed = False

Use of comments!

--Originally published at Start in the world of the #TC101

Well…after a long time, I’m going to start publish, and more like that I want to share what I have been learning in the class #TC010 with Ken…lets start!

The comments in Python are notes that you can use when your programs get bigger and more complicated, and this notes help you to know in  natural language what the program is doing and the symbol you use are #.

 

Like in this example: