9.17. Exercises¶
For each word in the list
verbs, add an -ing ending. Overwrite the old list so thatverbshas the same words withingat the end of each one.In XYZ University, upper level math classes are numbered 300 and up. Upper level English classes are numbered 200 and up. Upper level Psychology classes are 400 and up. Create two lists,
upperandlower. Assign each course inclassesto the correct list,upperorlower. HINT: remember, you can convert some strings to different types!Starting with the list myList = [76, 92.3, ‘hello’, True, 4, 76], write Python statements to do the following:
Append “apple” and 76 to the list.
Insert the value “cat” at position 3.
Insert the value 99 at the start of the list.
Find the index of “hello”.
Count the number of 76s in the list.
Remove the first occurrence of 76 from the list.
Remove True from the list using
popandindex.
The module
keyworddetermines if a string is a keyword. e.g.keyword.iskeyword(s)wheresis a string will return eitherTrueorFalse, depending on whether or not the string is a Python keyword. Import thekeywordmodule and test to see whether each of the words in listtestare keywords. Save the respective answers in a list,keyword_test.The
stringmodule provides sequences of various types of Python characters. It has an attribute calleddigitsthat produces the string ‘0123456789’. Import the module and assign this string to the variablenums. Below, we have provided a list of characters calledchars. Usingnumsandchars, produce a list calledis_numthat consists of tuples. The first element of each tuple should be the character fromchars, and the second element should be a Boolean that reflects whether or not it is a Python digit.