Question: Activity #1 With the given lists and tuples, hand trace the output of the codes below: testList = [11, 45, 8, 23, 14, 12, 78,


Activity #1 With the given lists and tuples, hand trace the output of the codes below: testList = [11, 45, 8, 23, 14, 12, 78, 45, 89] nameList= ['Lazarus','Luther','Orpheus','Raul','Rodolfo','Serafino','Silas','Vladamir'] a. print (namelist) b. print(nameList) print (nameList.index('Orpheus') nameList.remove('Silas') nameList.pop(5) nameList.pop(6) print(nameList) C. #try to search the Net on how to use the slice function in Python s1 = slice(3) s2 = slice(1,5, 2) print(" List slicing") print(testList[s1]) print(testList[s2]) d. print ("Initial values", testList) length=len(testList) chunkSize=int(length/3) start=0 end=chunkSize for i in range(1,4, 1); indexes=slice(start,end, 1) listChunk=testList [indexes] print("Chunk",i,list Chunk) listChunk.reverse() print('After reversing it', listChunk) start=end if(i != 2): end +=chunkSize else: end += length - chunkSize e. #assume that the user input 8 num=int(input("Enter an integer:")) divisorList=[] for i in range(2, num+1): if(num%i==0): divisorList.append(i) divisorList.sort() print(divisorList) print("Smallest divisor for", num, "is:", divisorList[0]) f. IstAge=[43,55,67,88,90,89] print (IstAge) #assume that user enter 24 45 57 age_data=input('please enter age separate by space') age=age_data.split() IstAge=[eval (x) for x in age] print (IstAge) e tplage=(43,55,67,88,90,89) print (tplage) #assume that user enter 24 45 57 age_data=input('please enter age separate by space') age=age_data.split() tplager(eval (x) for x in age) tplage.sort() print (tplage)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
