2026fa_cse160/lecture20261117/for01/for02.py
2026-11-17 12:30:27 -05:00

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)