12 lines
313 B
Python
12 lines
313 B
Python
# Program to print the sum of first 5 natural numbers
|
|
# https://beginnersbook.com/2018/01/python-for-loop/
|
|
# variable to store the sum
|
|
sum = 0
|
|
|
|
# iterating over natural numbers using range()
|
|
for val in range(1, 6):
|
|
# calculating sum
|
|
sum = sum + val
|
|
|
|
# displaying sum of first 5 natural numbers
|
|
print(sum)
|