Lecture 11/17/2026
This commit is contained in:
parent
07b9e54bf0
commit
bf3265103a
44 changed files with 1195 additions and 3 deletions
12
lecture20261117/for01/for02.py
Normal file
12
lecture20261117/for01/for02.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue