Program to print counting from 1 to 10 using while loop in Python.

Program to print counting from 1 to 10 using while loop in Python.

Write a program to print counting from 1 to 10 using while loop in Python.




In this post we will see a program to print counting from 1 to 10 using While loop. Let's start..!

In this program we want to print numbers from 1 to 10. For this we have to start a loop from 1 and end at 10. Now you know for such task we always use a loops. You can use any loop that you want but we are using while loop here. 

I have fully explained What is loops ? What is While loop ? and What is for loop ? 

If you don't know what is loops and what is while loop or for loop. Then you have to learn about loops first. Otherwise you will not understand such programs.


[ if don't know about loops and while loop then click here to learn more about Loops and While loop in Python ]

[ if don't know about for loop then click here to learn more about For loop in Python ]

Now we have to create a Algorithm to Write this program. Let's create Algorithm.

Algorithm :

step 01: Start

step 02: Create a variable 'count'

step 03: Initialize a count to 1 ( count = 1)

step 04: Check a condition ( count <= 10 ) in while loop. If condition is false then goto step 08. Or if condition is true then follow the following steps

step 05: Print the value of counter variable ( count )

step 06: Increment a counter by one i.e.(count = count + 1)

step 07: Goto step 04

step 08: Stop

Explanation :

The step 01 simply says start your algorithm or solution.

The step 02 simply says that create a variable named as count ( here your variable name can be anything not mandatory to have you variable name same as I shown here ) . this variable we will use as a counter.

[ if you don't know how to create variables then click here to learn more about Variables in Python ]

The step 03 says simply initialize your counter variable to 1 that is count = 1. 

The step 04 says that write a while loop and write a condition ( count <= 10 ) . And then simply check that condition is it true or false. If condition is false then directly jump on step no 08 that is stop. Or if condition is true then simply execute the while block.

[ if you don't know how to use while loop then click here to learn more about While loop in Python ]

The step 05 says that in while block simply print the value of counter variable that is count in this case.

The step 06 says that in while block increment your counter by one that is count = count + 1.

The step 07 says that goto step 04 and start again from there.

The step 08 says that your problem has solved so stop.

Now write a Program according to this algorithm. 


Program :


# start
# printing 1 to 10 numbers using while loop

# creating a counter variable named as count
# initializing a counter
count = 1

# using while loop
while count <= 10# condition 

    # printing a counter or number
    print(count)
    # incrementing a counter by one
    count = count + 1

# stop


Output :

Sample input and output


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10


Program to print counting from 1 to 10 using while loop in Python.


If you have any doubts in this post then please ask me in comment section below. I will try to solve it.

If you like these post and you have learned something from this then share this post with your friends and family.

Keep learning always.....!!! 😇😇😇




Previous Post  Next Post