Added lecture 2026113

This commit is contained in:
Edward Bigos 2026-11-03 12:49:45 -05:00
commit 5b630435ae
27 changed files with 738 additions and 0 deletions

View file

@ -0,0 +1,8 @@
#https://beginnersbook.com/2018/01/python-for-loop/
for val in range(5):
print(val)
else:
print("The loop has completed execution")

View 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)

View file

@ -0,0 +1,26 @@
print("\nSome demo range statements\n")
print("Print a range(6) ")
for x in range(6):
print(x)
else:
print("Finally finished!")
print("\n\nPrint a range(0, 3) ")
for x in range(0, 3):
print("Value of x = {:d}".format(x) )
print("\n\nPrint a range(45, 55) ")
for x in range(45, 55):
print("Value of x = {:d}".format(x) )
print("\n\nPrint a range(2, 30, 4) ")
for x in range(2, 30, 4):
print(x)
print("\n\nPrint a range(1, 11, 2) ")
for x in range(1, 11, 2):
print(x)

View file

@ -0,0 +1,5 @@
print("Break a string into characters.")
string = "Hello World"
for x in string:
print(x)

View file

@ -0,0 +1,7 @@
# https://beginnersbook.com/2018/01/python-for-loop/
for num1 in range(0,3):
for num2 in range(0, 3):
print(num1, ",", num2)

View file

@ -0,0 +1,12 @@
# https://www.programiz.com/python-programming/for-loop
scores = [70, 91, 85, 90, 100]
print(f"The length of this list of scores is {len(scores)}")
scoreSum = 0
for i in scores:
print(i)
scoreSum += i
else:
print("The average is ",scoreSum/len(scores))