Machine Learning Tutorial Python : 13. Python For Loop

Published: 21 February 2019
on channel: Vinoth QA Academy
1,262
16

#vision2020 #aiforeveryone #python :

"My Vision is to provide "AIFOREVERYONE", by creating free video courses for Artificial Intelligence ,
Machine Learning, Deep Learning and Data Science Aspirants!"

If you wish to support my #vision2020, kindly Like, Subscribe & Share this knowledge to your friends and colleagues.

Follow Me :

Materials: https://aiforevery1.com/numpy/

Udemy : https://www.udemy.com/user/vinoth-rat...

LinkedIn :   / vinothrathinamautomation  

Facebook :   / aiforevery1  

Github : https://github.com/vinothrwins

************************************************************
Playlist:

Artificial Intelligence for Beginners :    • Playlist  

Python for Artificial Intelligence :    • Python for Artificial Intelligence(Data Sc...  

Mathematics for Artificial Intelligence :    • Mathematics for Artificial Intelligence  

Python NumPy for Artificial Intelligence :    • Python NumPy for Artificial Intelligence  

Data Science Process :    • Playlist  

***********************************************************
Agenda :

What is For loop?
For loop with else statement
Looping through String
Range Function
Iterating by Sequence Index
Nested For Loop
12 Sample programs

***************************
Python Loops
***************************

A loop statement allows us to execute a statement or group of statements multiple times.

Python has two primitive loop commands:
• while loops
• for loops

***********
For Loop
***********

The for loop in Python is used to iterate over a sequence (list, tuple, string) or other iterable objects.
Iterating over a sequence is called traversal

***********
Syntax :
***********

for iterating_var in sequence:
statements(s)

The first item in the sequence is assigned to the iterating variable iterating_var.
Next, the statements block is executed. Each item in the list is assigned to iterating_var, and the statement(s) block is executed until the entire sequence is exhausted

********************************
Using else Statement with Loops
********************************

If the else statement is used with a for loop, the else statement is executed when the loop has exhausted iterating the list

**********************
The range() function
**********************

We can generate a sequence of numbers using range() function.
We can also define the start, stop and step size as range(start,stop,step size). step size defaults to 1 if not provided.
This function does not store all the values in memory, it would be inefficient. So it remembers the start, stop, step size and generates the next number on the go.

****************************
Iterating by Sequence Index
****************************

An alternative way of iterating through each item is by index offset into the sequence itself.

****************
Nested For Loop
****************

Python programming language allows to use one for loop inside another for loop

************************************************************
Kindly let me know your feedback for improvement purpose. Feel free to correct any mistakes in case !!

Happy Learning,
Vinoth Rathinam


On this page of the site you can watch the video online Machine Learning Tutorial Python : 13. Python For Loop with a duration of hours minute second in good quality, which was uploaded by the user Vinoth QA Academy 21 February 2019, share the link with friends and acquaintances, this video has already been watched 1,262 times on youtube and it was liked by 16 viewers. Enjoy your viewing!