-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ignacio Avas
committed
May 2, 2017
1 parent
b76a900
commit bebc6a8
Showing
5 changed files
with
120 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,54 @@ | ||
Boilerplate | ||
----------- | ||
Bucles While | ||
------------ | ||
|
||
Insertar alguna introducción aquí. | ||
En general las sentencias son ejecutadas secuencialmente: la primera sentencia es ejecutada el princio, seguida por la segunda, y así sucesivamente. En algunas situaciones es necesario ejecutar un bloque de código varias veces. El siguiente ejemplo imprimer los números del 1 al 100 y luego "Terminado" | ||
|
||
.. sourcecode:: python | ||
|
||
print('Some python code here') | ||
mynumber = 1 | ||
while mynumber < 100: | ||
print(mynumber) | ||
mynumber = mynumber + 1 | ||
print("Terminado!") | ||
|
||
Los lenguages de programación proveen varias estructuras de control que permiten flujos de control más complejos, entre los que se encuentran los búcles "while" y "for". | ||
|
||
Los bucles while, ejecutan las sentencias dentro de él siempre y cuando cierta condición se cumpla. Cuando la condición deja de cumplirse el flujo pasa a la línea exactamente luego del bucle. | ||
|
||
Bucles for | ||
---------- | ||
|
||
Los bucles for tienen la habilidad de iterar sobre los items de cualquier secuencia, ya sea lista o cadena de caracteres. | ||
|
||
.. sourcecode:: python | ||
ingredients = ['banana', 'manzana', 'mango'] | ||
for ingredient in ingredients: | ||
print('Ingrediente actual: {{0}}'.format(ingredient)) | ||
|
||
for some_char in 'Python': | ||
print(some_char) | ||
|
||
The previous example will generate the following output: | ||
|
||
.. sourcecode:: | ||
Ingrediente actual: banana | ||
Ingrediente actual: manzana | ||
Ingrediente actual: mango | ||
P | ||
y | ||
t | ||
h | ||
o | ||
n | ||
|
||
La función "range" puede ser usada para iterar sobre una lista de números | ||
|
||
.. sourcecode:: python | ||
for number in range(100): | ||
print(number) | ||
print("Fin!") | ||
|
||
Desafío | ||
------- | ||
|
||
Describir el desafío aquí. | ||
Usando sentencias while for e if, escribe un programa que imprima todos los números impares del 1 al 100, uno por línea. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,54 @@ | ||
Boilerplate | ||
While loops | ||
----------- | ||
|
||
Insert some introduction here. | ||
In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. There may be a situation when is need to execute a block of code several number of times. The following example will print the number 1 through 100 and then "Done!": | ||
|
||
.. sourcecode:: python | ||
|
||
print('Some python code here') | ||
mynumber = 1 | ||
while mynumber < 100: | ||
print(mynumber) | ||
mynumber = mynumber + 1 | ||
print("Done!") | ||
|
||
Programming languages provide various control structures that allow for more complicated execution paths. They are "while" loops and "for" loops | ||
|
||
While loops, which repeatedly executes a target statement as long as a given condition is true. When the condition becomes false, program control passes to the line immediately following the loop. | ||
|
||
For loops | ||
--------- | ||
|
||
The for loops have the ability to iterate over the items of any sequence, such as a list or a string. | ||
|
||
.. sourcecode:: python | ||
ingredients = ['banana', 'apple', 'mango'] | ||
for ingredient in ingredients: | ||
print('Current ingredient: {{0}}'.format(ingredient)) | ||
|
||
for some_char in 'Python': | ||
print(some_char) | ||
|
||
The previous example will generate the following output: | ||
|
||
.. sourcecode:: | ||
Current ingredient: banana | ||
Current ingredient: apple | ||
Current ingredient: mango | ||
P | ||
y | ||
t | ||
h | ||
o | ||
n | ||
|
||
Also the "range" function can be used to iterate through a list of numbers | ||
|
||
.. sourcecode:: python | ||
for number in range(100): | ||
print(number) | ||
print("Done!") | ||
|
||
Challenge | ||
--------- | ||
|
||
Describe the challenge here | ||
Using while, for and if statements, write a program that prints all the odd integers from 1 through 100, one per line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. sourcecode:: python | ||
|
||
print('Some solution here') | ||
for number in range(100): | ||
if number % 2 == 1: | ||
print(number) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters