Answered step by step
Verified Expert Solution
Question
1 Approved Answer
def print _ list ( lst ) : print ( ' , ' . join ( lst ) ) # 2 def start _ with
def printlistlst: printjoinlst # def startwithcountlst char: return sum for item in lst if item.startswithchar # def doublelistlst: doubledlist for car in lst: doubledlist.extendcar car return doubledlist # def printreversedlst: reversedlist for i in rangelenlst: reversedlist.appendlsti printreversedlist # def rotatelistlst: rotated lst:lst return rotated # def calavglst: totallength sumlenitem for item in lst return totallength lenlst if namemain: carlist Chevrolet 'Cadillac', 'Buick', GMC 'Ford', 'Jeep', 'Dodge', 'Tesla', 'Austin' printHere is the list: printlistcarlist printThe number of cars start with C is: startwithcountcarlist, C printThe list doubled: printdoublelistcarlist printThe list reversed: printreversedcarlist printThe list after a right rotate: printrotatelistcarlist printThe average length of the list items is: f calavgcarlist
def printlistlst:
printjoinlst
#
def startwithcountlst char:
return sum for item in lst if item.startswithchar
#
def doublelistlst:
doubledlist
for car in lst:
doubledlist.extendcar car
return doubledlist
#
def printreversedlst:
reversedlist
for i in rangelenlst:
reversedlist.appendlsti
printreversedlist
#
def rotatelistlst:
rotated lst:lst
return rotated
#
def calavglst:
totallength sumlenitem for item in lst
return totallength lenlst
if namemain:
carlist Chevrolet 'Cadillac', 'Buick', GMC 'Ford', 'Jeep', 'Dodge', 'Tesla', 'Austin'
printHere is the list:
printlistcarlist
printThe number of cars start with C is: startwithcountcarlist, C
printThe list doubled:
printdoublelistcarlist
printThe list reversed:
printreversedcarlist
printThe list after a right rotate:
printrotatelistcarlist
printThe average length of the list items is: f calavgcarlist
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started