For

For

The flowchart of a for is like it follows:

for_1.PNG

This is the basic structure:

for_0.PNG

val is a certain value or ‘conditional’

Here is one example

for_2.PNG

for_3.PNG

Important information about for´s:

  • The for statement in Python has the ability to iterate over the items of any sequence, such as a list or a string.
  • If a sequence contains an expression list, it is evaluated first. Then, the first item in the sequence is assigned to the iterating variable iterating_var. Next, the statements block is executed. Each item in the list is assigned to iterating_var, and the statement(s) block is executed until the entire sequence is exhausted.

References:

http://www.programiz.com/python-programming

http://www.tutorialspoint.com/python3/

Fruit Loops the revenge

In this post I´ll explain the missing loops, those are: elif, while and for. So  let´s get started.

Elif

This is the flowchart of an elif

elif.jpg

this is how it works

elif.PNG

and here is one example

elif_1.jpg

Important information about elif:

  • The elif is short for else if.It allows us to check for multiple expressions.
  • If the condition for if is False, it checks the condition of the next elif block and so on.
  • If all the conditions are False, body of else is executed.
  • Only one block among the several if…elif…else blocks is executed according to the condition.
  • The if block can have only one else block. But it can have multiple elif blocks.

For

The flowchart of a for is like it follows:

for_1.PNG

This is the basic structure:

for_0.PNG

val is a certain value or ‘conditional’

Here is one example

for_2.PNG

for_3.PNG

Important information about for´s:

  • The for statement in Python has the ability to iterate over the items of any sequence, such as a list or a string.
  • If a sequence contains an expression list, it is evaluated first. Then, the first item in the sequence is assigned to the iterating variable iterating_var. Next, the statements block is executed. Each item in the list is assigned to iterating_var, and the statement(s) block is executed until the entire sequence is exhausted.

References:

http://www.programiz.com/python-programming

http://www.tutorialspoint.com/python3/

Fruit-Loops

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