Header Ads Widget

Write a program to print first N natural numbers in Python. (N is given by user)

Write a program to print first N natural numbers in Python. (N is given by user) 

Given a number n , write a program to print the first n natural numbers . Value of n is given by user .

Sample input:

10

Sample output:

 List of Natural Numbers from 1 to 10 are 
 1  2  3  4  5  6  7  8  9  10

Write a program to print first N natural numbers in Python. (N is given by user) 

The objective of the code is to print the first n natural number . n is given by the user .

Code(Python):-

print("Please Enter any Integer Value : ")
n=int(input())
print(f"List of Natural Numbers from 1 to {n} are ")
for i in range(1,n+1):
print(i,end=" ")

Output:-
Please Enter any Integer Value :
10
List of Natural Numbers from 1 to 10 are
1 2 3 4 5 6 7 8 9 10


Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-


 

Post a Comment

0 Comments