CODE :
# sumn.py
# Write a program to find the sum of the first n natural numbers,
#where the value of n is provided by the user.
def main() :
sum=0
n = int (input ("Please enter number: ") )
for i in range(n+1) :
sum=sum+i
print ("Sum of n Natural number is :",sum)
main()
NOte : save this file as sumn.py
SCREENSHOT :
No comments:
Post a Comment