Syntax and example of Python For loop by shadbox.com

Total Blog Views: 46

Blog Status: publish

Created By: swazahmad Created at: 07-26-2021

Tags: python

This tutorial is helps you to learn "For Loop" using python by team SHADBOX.COM

For loop :

  • In all the programming language loop is used to iterate the statement or a part of the program.

For loop in python :

  • In python For loop is also used to iterate the part of the program.
  • it is used to traverse the data structure like list,tuples,or dictionary.

Syntax :

                    for iterating_var in Sequence:
                              Statements.....

Examples :

     >>> for i in range(0,10):
         print(i)
 
 
     0 
     1
     2
     3  
     4
     5
     6
     7
     8
     9
     >>> 
 

printing table of the given number :

 
     >>> n = int(input("Enter number :"))
     Enter number : 5
     >>> for i in range(1,11):
         print(n * i)
 
 
     5
     10
     15 
     20
     25
     30
     35
     40
     45
     50
     >>> 
 

Exercise : comment your Answer ,
Write a program to sum of integer from 1 to 10 using for loop.

 


swazahmad

Swaz is Practice Lead of ROR Developer. he's a Blogger, Mentor, and Rubyst. He has expertise in Javascript also . he's highly skilled in designing, developing and testing web applications. He enjoys being challenged and interesting with projects that need him to



Comments



  • swazahmad | almost 4 years ago
    Awesome Information Thanks For Sharing
Buy traffic for your website

About Shadbox

we have the “Get things executed” lifestyle at our place of work. There are not any excuses, no if’s or however’s in our dictionary. committed to navigating the ship of creativity to create cell answers, we resolve the real-lifestyles troubles of our clients and their clients. Our passion for work has won us many awards, year after 12 months.

Services

Downloads