Print first 10 natural numbers using while loop in Python
In this post, you will learn how to print the first 10 natural numbers using a while loop in the Python programming language. Such a type of logical question is generally asked in an interview or in competitive exams. This can be helpful to improve your logical programming skills and other logical application development.
Print numbers from 1 to 10 using while loop
In the given example, first we initialised a variable input with 1 and iterated over the loop until the number is less than or equal to 10. Then we print the value of input.
input = 1
while input <= 10:
print(input)
input += 1
Output of the above code:
1
2
3
4
5
6
7
8
9
10
Related Articles
Countdown clock and timer using Tkinter in Python
Simple Calculator Program in Python
Python gmplot to add google map on a web page
Python requests GET method
Python OpenCV ColorMap
Python program to input week number and print week day
Python program to list even and odd numbers of a list
Python program to print odd numbers within a given range
Python program to multiply two numbers
Program to find area of triangle in Python
Find area of rectangle in Python
Swapping of two numbers in Python
Find average of n numbers in Python
Print multiplication table in Python
Python program to multiply two matrices
Python program to find area of circle
Python iterate list with index
Python add list to list
Python random choice
Python dict inside list
Count consonants in a string Python
Convert array to list Python