Friday 1 January 2021

Python program to print 10 to 1 using while

 Following Python program will print 10 to 1 numbers using while loop. 

Expected Output: 10 9 8 7 6 5 4 3 2 1


Program Code:

number = 10

while number >= 1:
  print(number, end=" ")
  number = number - 1


Output of Program:

10 9 8 7 6 5 4 3 2 1


* * * * *


< Back to Python Loops >

< Back to Home >

Python program to print 1 to 10 using while loop

Following Python program will print 1 to 10 numbers using while loop. 

Expected Output: 1 2 3 4 5 6 7 8 9 10


Program Code:

number = 1

while number <= 10:
  print(number, end=" ")
  number = number + 1


Output of Program:

1 2 3 4 5 6 7 8 9 10


* * * * *


< Back to Python Loops >

< Back to Home >