PyCodePro

Previously LP16 - A website that teaches Python programming language through interactive tutorials, practice exercises, and real-world projects.

Applications of Range Function

Applications of Range Function

In our previous blog we learn about the Range function now in this blog we discuss about the Applications of the range function – 

How to use range function –

range ( < lower linit > , < upper limit > )

now to print the series of the numbers we use for loop and the range function at the same time –

for example –

for loop
a – variable 
in – function 
range – range function
lower limit , upper limit – limit to display the numbers . 
:   - quotes after the the end of the range function
Print the variable  
 now combine all these simplicities – 

for a in range ( 0 , 10 ):
print ( a )

now the most important thing is that the range steps will end before the one step to write in the upper limit .

for example –

range ( 10 )
output – 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9
range ( 5 , 10 )
output – 5 , 6 , 7 , 8 , 9

now the other applications of the range function are –

range ( 0 , 10 , 2 )

the 0 is the starting point

10 is the stopping point

2 is the difference between the starting and stopping point

range ( 0 , 10 , 2 )
Output – 0 , 2 , 4 , 6 , 8

Now the python will stop the series at 8 because we know that the python will stop range function before one step and now the series will stop at 9 but we enter the difference between starting point and the stopping point is 2 so that the series will stop at 8

The other application of range function is –
Range ( 10 , 2 , -1 )

The minus in the last will reverse the series in the difference of 1

Range ( 10 , 2 , -2 )
Output – 10 , 8 , 6 , 4

Now we will discuss further in the next blog


IN THE NEXT BLOG WE LEARN ABOUT THE STORING VALUES IN PYTHON AND OTHER IMPORTANT SUB TOPICS  
THANK YOU FOR VISITING 
KEEP VISITING
KEEP LEARNING 
STAY TUNED FOR NEXT BLOG
VIEW OUR PREVIOUS BLOG FOR THE BASIC CONCEPTS OF PYTHON AND OTHER BASIC CONCEPTS OF COMPUTER AND ALSO FOR THE IMPORTANT DEFINITIONS OF THE SQL
VISIT OUR SECOND BLOG – indianbasics.blogspot.com
VISIT OUR YOUTUBE CHANNEL -  Learn Python 
Our youtube channel will give you the short motivational speeches of the great person in the present there is only one motivational video on channel but in future I will upload the motivational videos soon .
VISIT OUR INSTAGRAM PAGE – instagram.com/learnpython16
Out instagram page is also a new page i9 have just crated few hours ago but stay tuned I will upload the post very soon . 
Please support us by following our blog and by subscribing our youtube channel and by following our instagram page .

Applications of Range Function Applications of Range Function Reviewed by Learn Python on November 30, 2019 Rating: 5

No comments:

Powered by Blogger.