Python- Loops intro

Good Day Boys.

Let us start one of the most important topic in any Programing Language- LOOPING

The Google meet link is

Meeting ID

----------------------------------------------------------------------------------------------------
By the end of this session, you will be able to
  • Understand the purpose of the iterative construct
  • Understand the Basic Construct of looping
  • Understand the advantages of an iterative construct
--------------------------------------------------------------------------------------------------- 



Python Loops
  • The flow of the programs written in any programming language is sequential by default.
  • Sometimes we may need to alter the flow of the program. 
  • The execution of a specific code may need to be repeated several numbers of times.
  • For this purpose, the programming languages provide various types of loops which are capable of repeating some specific code several numbers of times.
  • Iteration is defined as the act or process of repeating. For example, iteration can include repetition of a sequence of operations in order to get ever closer to a desired result. 
  • Iteration can also refer to a process wherein a computer program is instructed to perform a process over and over again repeatedly for a specific number of times or until a specific condition has been met.
  • Consider the following diagram to understand the working of a loop statement.

Python Loops

Why we use loops in python?

·         The looping simplifies the complex problems into the easy ones. 

·         It enables us to alter the flow of the program so that instead of writing the same code again and again, we can repeat the same code for a finite number of times.

·          For example, if we need to print the first 10 natural numbers then, instead of using the print statement 10 times, we can print inside a loop which runs up to 10 iterations.

Advantages of loops

There are the following advantages of loops in Python.

1.   It provides code re-usability.

2.   Using loops, we do not need to write the same code again and again.

Comments

Post a Comment

Popular posts from this blog

HOLIDAY HW