Python While loop for beginner by shadbox

Total Blog Views: 47

Blog Status: publish

Created By: swazahmad Created at: 08-03-2021

Tags: python coding while loop

python while loop :

  • The while loop is also known an precondition loop.
  • While loop allows the part of code to be executed when the given condition is true.

 

  • while loop is mostly used where the number of iteration is not known in advance.
Syntax : 
                  While Expression(condition):
                          Statements.......
 

Example :

     >>>i =1
     >>> while i<=10:
     print(i)
     i = i+1
 
 
     1
     2 
     3
     4
     5
     6
     7
     8
     9
     10
     >>> 
 

printing the table of the given number using While loop :

     >>> i = 1
     >>> n = int(input("Enter number :"))
     Enter number :10
     >>> while i<=10:
         print(n * i)
         i = i+1
 
 
     10 
     20
     30
     40
     50
     60
     70
     80
     90
     100
     >>> 
 

Exercise : write a program to find even number in range 1 to 10 using while loop ,comments your answer. 

 


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



  • vishnu | almost 4 years ago
    Bravo Dude can you provide your insta id
  • 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