Lecture 11/17/2026
This commit is contained in:
parent
07b9e54bf0
commit
bf3265103a
44 changed files with 1195 additions and 3 deletions
15
lecture20261117/for01/for01.py
Normal file
15
lecture20261117/for01/for01.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Program to print squares of all numbers present in a list
|
||||
# https://beginnersbook.com/2018/01/python-for-loop/
|
||||
|
||||
# List of integer numbers
|
||||
numbers = [1, 2, 4, 6, 11, 20]
|
||||
|
||||
# variable to store the square of each num temporary
|
||||
sq = 0
|
||||
|
||||
# iterating over the given list
|
||||
for val in numbers:
|
||||
# calculating square of each number
|
||||
sq = val * val
|
||||
# displaying the squares
|
||||
print(sq)
|
||||
Loading…
Add table
Add a link
Reference in a new issue