Pages

Sunday, January 28, 2018

Control Flow Tools Part 2 Python

Control flow tools in Python are a basic necessity for anyone going into the database and business intelligence fields. When creating these statements they may help you out to complete certain tasks efficiently. We shall look into the Range functions as well as the else clauses.


Range Functions

Guido states that "If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy. It generates arithmetic progressions." (Guido Van Rossum 4.3)
 
Here is an example of the Range function:


With the range function it stated that for I in range between 0-5 print I and when the sequence is entered, the range between 0-5 is "printed".

Here is my take on the function:


As stated previously I is in range between 0-15 and when the sequence is executed the function entered 15 numbers!

Else Clauses

Loop statements may have an else clause. which is executed when the loop terminates through exhaustion of the list (with for) or when the condition becomes false (with while), but not when the loop is terminated by a break statement. Here is an example to better understand the statement.

And now is my take on this sequence:


That is all for now, a question left to ponder for all of you is. When did you guys get your first computers?

0 comments:

Post a Comment