martes, 10 de febrero de 2015

#Mastery20 'for' loops

"Python’s for statement iterates over the items of any sequence (a list or a string), in the order that they appear in the sequence."(Original text.)

In this case the loop of for prints over the sequence of numbers given by the user. Due to the way that python sets up sequences it was real E-Z to make the user determine the way that the numbers will go up. The range of numbers is exclusive, that means that it wont include the very last númber of the sequence, I represented that in the program with a '>'. 

example: 
for i in range(0,11,5):
     print (i)
In this case the program will loop until every single value of i is printed. i is in range from 0 to 10, and it will go up by 5. Which means that it will appear: 0,5,10. 

No hay comentarios:

Publicar un comentario