Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/feed-rss2.php on line 8
‘#VML’ Articles at Courses by Ken https://kenscourses.com/tc101winter2015 Facilitator of Learning Experiences Sun, 05 Apr 2015 06:05:44 +0000 en hourly 1 https://creativecommons.org/licenses/by/4.0/ Creation and use of Ranges. Mastery 25. https://kenscourses.com/tc101winter2015/2015/creation-and-use-of-ranges-mastery-25/ Sun, 05 Apr 2015 06:05:44 +0000 https://ismalga.withknown.com/2015/creation-and-use-of-ranges-mastery-25 Continue reading ]]>

The range function of Python allow us to create that, ranges. A sequence of numbers. It can be used with one, two or three parameters. Examples to be explained.

One parameter:

A one parameter range, is written by putting the word range followed by a parenthesis with a number. Example:

But, what numbers does this range contain inside of it? Let’s use the list function to find out…

We can see that range(8) contains numbers from 0 to 8. Therefore, range(n) contains numbers from 0 to n-1.

Two Parameter:

A range with two parameter is written with 2 numbers separated by a coma inside the parenthesis. Example:

What numbers does this range contains inside of it? Let’s find out…

This range contains numbers from two to six. Therefore, range(a,b) contains numbers from a to b-1.

Three paratemers:

If we use three parameters, the third one represents the increment between each value of the sucesion. The first one is the initial parameter, the second one the upper value not included. Example:

This range contains number starting from 2, increasing by 3 until 24.

Ranges also work with negative numbers. The range function is used commonly alongside for loops.

]]>
https://creativecommons.org/licenses/by/4.0/