Magicians = ['Alice','David','Carolina']#For Loop Operation forMagicianinchMagicians:#do not omit the colon Print(magician)Print(Magician.title () +', that is a great trick') Print("I can ' t wait to see your next trick,"+ magician.title () +". \ n") Print('Thank You,everyone. That is a great magic show!') forValueinchRange (1,5):#using the Range function Print(value) numbers= List (range (1,6))Print(numbers) even_numbers= List (range (2,11,2))Print(even_numbers) Squares=[] forValueinchRange (1,11): Square= Value**2squares.append (square)Print(squares) Squares= [value**2 forValueinchRange (1,11)]Print(squares) digits= [1,2,3,4,5,6,7,8,9,0]#Simple Statistical calculationPrint(min (digits))Print(max (digits))Print(sum (digits)) Players= ['Charles','Martina','Michael','Florence','Eli']#slicesPrint(Players[0:3])Print(Players[1:4])Print(Players[:3])Print(players[2:])Print(players[-3:]) Players= ['Charles','Martina','Michael','Florence','Eli']Print("Here is the first three players on my team:")#For loop traversal slices forPlayerinchPlayers[:3]: Print(Player.title ()) My_foods= ['Pizza','Falafel','Carrot Cake',]friend_foods=My_foods[:]my_foods.append ('Cannali') Friend_foods.append ('Ice Creame')Print('My favourate Foods is:')Print(my_foods)Print("\nmy friend ' s favourate Foods is:")Print(friend_foods)Print("The first three iteams in the list is:")Print(My_foods[0:4]) Dimensions= (200,5)#traversing tuples all valuesPrint(Dimensions[0])Print(dimensions[1]) forDimensioninchDimensions:Print(dimension) dimension= (200,50)#Modifying tuple variablesPrint("Original Dimensions:") forDimensioninchDimensions:Print(dimension) dimensions= (400,10)Print("\nmodified Dimensions:") forDimensioninchDimensions:Print(dimension)
List and tuple operations. PY