• Latest
  • Trending
Looping Statements in Python

Looping Statements in Python

July 13, 2022
Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

July 29, 2025
French Telco Orange Hit by Cyber-Attack

French Telco Orange Hit by Cyber-Attack

July 29, 2025
ATC Ghana supports Girls-In-ICT Program

ATC Ghana supports Girls-In-ICT Program

April 25, 2023
Vice President Dr. Bawumia inaugurates  ICT Hub

Vice President Dr. Bawumia inaugurates ICT Hub

April 2, 2023
Co-Creation Hub’s edtech accelerator puts $15M towards African startups

Co-Creation Hub’s edtech accelerator puts $15M towards African startups

February 20, 2023
Data Leak Hits Thousands of NHS Workers

Data Leak Hits Thousands of NHS Workers

February 20, 2023
EU Cybersecurity Agency Warns Against Chinese APTs

EU Cybersecurity Agency Warns Against Chinese APTs

February 20, 2023
How Your Storage System Will Still Be Viable in 5 Years’ Time?

How Your Storage System Will Still Be Viable in 5 Years’ Time?

February 20, 2023
The Broken Promises From Cybersecurity Vendors

Cloud Infrastructure Used By WIP26 For Espionage Attacks on Telcos

February 20, 2023
Instagram and Facebook to get paid-for verification

Instagram and Facebook to get paid-for verification

February 20, 2023
YouTube CEO Susan Wojcicki steps down after nine years

YouTube CEO Susan Wojcicki steps down after nine years

February 20, 2023
Inaugural AfCFTA Conference on Women and Youth in Trade

Inaugural AfCFTA Conference on Women and Youth in Trade

September 6, 2022
  • Consumer Watch
  • Kids Page
  • Directory
  • Events
  • Reviews
Wednesday, 15 April, 2026
  • Login
itechnewsonline.com
  • Home
  • Tech
  • Africa Tech
  • InfoSEC
  • Data Science
  • Data Storage
  • Business
  • Opinion
Subscription
Advertise
No Result
View All Result
itechnewsonline.com
No Result
View All Result

Looping Statements in Python

by ITECHNEWS
July 13, 2022
in Data Science, Leading Stories
0 0
0
Looping Statements in Python

The flow of the programs written in any programming language is sequential by default. The first statement in a function is executed first, followed by the second, and so on. There may be a situation when the programmer needs to execute a block of code several times. For this purpose, The programming languages provide various kinds of loops that are able to repeat some particular code numerous numbers of times. Here, we are going to talk about looping statements in Python.

In a programming language, a looping statement contains instructions that continually repeat until a certain condition is reached. Read on to find out more about them.

YOU MAY ALSO LIKE

French Telco Orange Hit by Cyber-Attack

ATC Ghana supports Girls-In-ICT Program

Looping statements in Python

Looping simplifies complicated problems into smooth ones. It allows programmers to modify the flow of the program so that rather than writing the same code, again and again, programmers are able to repeat the code a finite number of times.

In Python, there are three different types of loops: for loop, while loop, and nested loop.

Here, we will read about these different types of loops and how to use them.

 

For Loop

The for loop is used in the case where a programmer needs to execute a part of the code until the given condition is satisfied. The for loop is also called a pre-tested loop. It is best to use for loop if the number of iterations is known in advance.

In Python, there is no C style for loop, i.e., for (i=0; i<n; i++).

Syntax:

for variable in sequence:
    statements(s)

Input:

a = 5
for i in range(0, a):
    print(i)

Output:

0
1
2
3
4

The for loop runs till the value of i is less than a. As the value of i is 5, the loop ends.

While Loop

The while loop is to be used in situations where the number of iterations is unknown at first. The block of statements is executed in the while loop until the condition specified in the while loop is satisfied. It is also called a pre-tested loop.

In Python, the while loop executes the statement or group of statements repeatedly while the given condition is True. And when the condition becomes false, the loop ends and moves to the next statement after the loop.

Syntax:

While condition:
       statement(s)

Input:

count = 0
while (count < 5):   
    count = count + 1
    print("Flexiple")

Output:

 

Flexiple
Flexiple
Flexiple
Flexiple
Flexiple

The loop prints ‘Flexiple’ till the value of count becomes 5 and the condition is False.

Nested Looping statements in Python

The Python programming language allows programmers to use one looping statement inside another looping statement.

Syntax:

#for loop statement
for variable in sequence:
    for variable in sequence:
       statement(s)
       statement(s)

while loop statement

while condition:
while condition:
statement(s)
statement(s)



Input:

 

for i in range(1, 7):
    for j in range(i):
         print(i, end=' ')
    print()



Output:

 

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6



Closing Thoughts

In this tutorial, we read about different looping statements in Python and their uses. The looping statements are used to repeat a specific block of code various number of times. One can read about other Python concepts here.

Source: hrishikesh1990
Tags: Looping Statements in Python
ShareTweet

Get real time update about this post categories directly on your device, subscribe now.

Unsubscribe

Search

No Result
View All Result

Recent News

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

July 29, 2025
French Telco Orange Hit by Cyber-Attack

French Telco Orange Hit by Cyber-Attack

July 29, 2025
ATC Ghana supports Girls-In-ICT Program

ATC Ghana supports Girls-In-ICT Program

April 25, 2023

About What We Do

itechnewsonline.com

We bring you the best Premium Tech News.

Recent News With Image

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

July 29, 2025
French Telco Orange Hit by Cyber-Attack

French Telco Orange Hit by Cyber-Attack

July 29, 2025

Recent News

  • Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa July 29, 2025
  • French Telco Orange Hit by Cyber-Attack July 29, 2025
  • ATC Ghana supports Girls-In-ICT Program April 25, 2023
  • Vice President Dr. Bawumia inaugurates ICT Hub April 2, 2023
  • Home
  • InfoSec
  • Opinion
  • Africa Tech
  • Data Storage

© Copyright 2026, All Rights Reserved | iTechNewsOnline.Com - Powered by BackUPDataSystems

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist

No Result
View All Result
  • Home
  • Tech
  • Africa Tech
  • InfoSEC
  • Data Science
  • Data Storage
  • Business
  • Opinion

© Copyright 2026, All Rights Reserved | iTechNewsOnline.Com - Powered by BackUPDataSystems

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
Go to mobile version