Added code for lecture 2026-11-10

This commit is contained in:
Edward Bigos 2026-11-10 12:28:09 -05:00
commit 07b9e54bf0
52 changed files with 1248 additions and 1 deletions

View file

@ -0,0 +1,33 @@
# https://www.w3schools.com/python/python_ref_list.asp
# https://www.quackit.com/python/reference/python_3_list_methods.cfm
programMessage = '''
A deep copy is a new copy of an existing object. This copy demonstrates
this principle.
1.) Create a list.
2.) Create a new copy from the original list.
3.) Show the id's of the objects are the different.
4.) Append a value to basicList then show the copy in myList has not changed.
'''
print(programMessage)
basicList = [1, 34, 99, 87, 14]
print(f"Before copy {basicList}")
myList = basicList.copy()
print(f"After copy {basicList} ==> {myList}")
print(f"After copy {id(basicList)} <= Not Equal => {id(myList)}")
print("\n")
print("Append a value to basicList. Examine any changes to myList\n")
#basicList = [1, 34, 99, 87, 14]
#myList = basicList.copy()
print(f"Before append to basicList {basicList}")
basicList.append(777)
print(f"basicList - After append {basicList}")
print(f"myList - After append {myList}")
print(f"After append {id(basicList)} <= Not Equal => {id(myList)}")