Added lecture 2026113
This commit is contained in:
parent
be356ccb59
commit
5b630435ae
27 changed files with 738 additions and 0 deletions
18
lecture20261103/lists01/list02.py
Normal file
18
lecture20261103/lists01/list02.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
|
||||
myList = [ 7, 5, 3, 9.5 ,11, 9999, "bob"]
|
||||
|
||||
|
||||
print("The list is ",myList)
|
||||
print("The type is ",type(myList))
|
||||
print("The length is ", len(myList) )
|
||||
print("\n")
|
||||
|
||||
counter = 0
|
||||
while(counter < len(myList)) :
|
||||
print(f"{counter} {myList[counter]} \t{type(myList[counter])}")
|
||||
counter = counter + 1
|
||||
|
||||
|
||||
|
||||
|
||||
27
lecture20261103/lists01/list03.py
Normal file
27
lecture20261103/lists01/list03.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
|
||||
myList = [ 7, 5, 3, 9,11]
|
||||
|
||||
|
||||
print("The list is ",myList)
|
||||
print("The type is ",type(myList))
|
||||
print("The length is ", len(myList) )
|
||||
print("\n")
|
||||
|
||||
for dummy in myList:
|
||||
print(f"{dummy:3d} {dummy**2:4d} {dummy**3:5d}")
|
||||
|
||||
print("Done!")
|
||||
for listElement in myList:
|
||||
print(f"{listElement:3d} {listElement**2:4d} {listElement**3:5d}")
|
||||
|
||||
print("Done!")
|
||||
|
||||
for x in myList:
|
||||
print(f"{x:3d} {x**2:4d} {x**3:5d}")
|
||||
|
||||
print("Done!")
|
||||
|
||||
|
||||
|
||||
|
||||
18
lecture20261103/lists01/lists01.py
Normal file
18
lecture20261103/lists01/lists01.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
|
||||
myList = [ 7, 5, 3, 9]
|
||||
|
||||
|
||||
print(myList)
|
||||
print(type(myList))
|
||||
|
||||
print( "Length of the list is ",len(myList) )
|
||||
|
||||
print(myList[0])
|
||||
print(myList[1])
|
||||
print(myList[2])
|
||||
print(myList[3])
|
||||
|
||||
|
||||
# This generates an error when you uncomment it
|
||||
#print(myList[4])
|
||||
8
lecture20261103/lists01/names.py
Normal file
8
lecture20261103/lists01/names.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
firstNames = [ "Harry", "Rusty", "Katrina", "Jack", "Gimli","Shenanigans", "Mandy"]
|
||||
|
||||
print(firstNames)
|
||||
print("The length is ",len(firstNames))
|
||||
|
||||
for firstName in firstNames:
|
||||
print(firstName)
|
||||
14
lecture20261103/lists01/names2.py
Normal file
14
lecture20261103/lists01/names2.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
firstNames = [ "Harry", "Rusty", "Katrina", "Jack", "Gimli","Shenanigans", "Mandy"]
|
||||
|
||||
print(firstNames)
|
||||
print(len(firstNames))
|
||||
|
||||
for firstName in firstNames:
|
||||
print(firstName)
|
||||
|
||||
firstNames.sort()
|
||||
print(firstNames)
|
||||
for firstName in firstNames:
|
||||
print(firstName)
|
||||
|
||||
11
lecture20261103/lists01/powers.py
Normal file
11
lecture20261103/lists01/powers.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
powersList = [0,1,2,3,4,5,6,7,8,9,10]
|
||||
|
||||
# Try this form
|
||||
#powersList = range(0,11)
|
||||
|
||||
print("The list is ", powersList)
|
||||
|
||||
for n in powersList:
|
||||
powerOfTwo = 2**n
|
||||
print(f"{n:2d} {powerOfTwo:8d}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue