When to use what type of repetition in a program

--Originally published at My B10g

Types of repetition

The while loop: for indefinite number of repetitions(use more cpu)

captura-de-pantalla-2016-10-26-a-las-11-18-13

The for loop: for an specific number of repetitionscaptura-de-pantalla-2016-10-26-a-las-11-18-39

 

Nested loops – loops within loops: run a process which run other process and the first process will not run again until the nestes process finished runningcaptura-de-pantalla-2016-10-26-a-las-11-19-19

The recursion: repeats until it gets to one case which doesn’t call itself, used to reduce coding.

captura-de-pantalla-2016-10-26-a-las-11-22-24

more interesting stuff in: http://www.annedawson.net/Python3_Repetition_StringFormatting.htm

beautiful poem of the day

ef377f7286a930fb0c97b1a712f3d605

.