Program to print the first 20 natural numbers

In this program, we will print the first 20 natural numbers using a while loop.

Steps to solve the program
  1. Create a variable and assign its value equal to 1.
  2. While the value of the variable is less than 21 print the variable.
  3. Add 1 to the count variable after printing a number.
  4. Print the output.
				
					count = 1

while count < 21:
    print(count,end=" ")
    count += 1
				
			

Output :

				
					1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 
				
			

print the keys and values of a dictionary

Print the table of a number using a while loop

Leave a Comment