Write a Python Program to Print Natural Numbers using While Loop and For Loop with an example.
See
the
Example
See
the
OutPut
# Python Program to Print Natural Numbers from 1 to Nnumber = int(input("Please Enter any Number: "))print("The List of Natural Numbers from 1 to {0} are".format(number))for i in range(1, number + 1): print (i, end = ' ')
See
the
While loop
Please Enter any Number: 10The List of Natural Numbers from 1 to 10 are1 2 3 4 5 6 7 8 9 10
Python Natural Numbers Program using While Loop
%
# Python Program to Print Natural Numbers from 1 to Nnumber = int(input("Please Enter any Number: "))i = 1print("The List of Natural Numbers from 1 to {0} are".format(number))while ( i <= number): print (i, end = ' ') i = i + 1
Output
Please Enter any Number: 25The List of Natural Numbers from 1 to 25 are1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25