A Smarter Way to Learn Python / Chapter 15 Exercises

  • Index of exercises
  • Email me

1

2

3

4

5

6

7

8

9

10

11

12

 

Congratulations. You've aced all the exercises for this chapter.


To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to Trinket.


Post a review on Amazon for the paperback or the Kindle edition.


Email me to give me a compliment, complaint, or correction. I'll respond.


  All of my books include free interactive online exercises that make the knowledge stick.

A Smarter Way to Learn JavaScript
Shop for it at Amazon
A Smarter Way to Learn HTML and CSS
Shop for it at Amazon
A Smarter Way to Learn jQuery
Shop for it at Amazon

copyright © 2017 by Mark Myers. All rights reserved.

0,1,2,3,4,5,6,7,8,9,10,11

0

0

0

0


What is players? (one word) players = ["Jane", "Jen", "Jill"] list^ *list *$
Type the two characters that are missing from this list definition. scores = 78, 47, 3, 52, 16 []^ *\[\] *$
The last element in the list is 0. Complete the list definition. qtys = [144, 12, 16__________, 0] , `0`]
Define a list, noncolors, that has a single element, "black". noncolors = ["black"]noncolors = ["black"]
What is the index number of a list's first element? 0 ^ *0 *$
A list contains 20 elements. What is the index number of the last element? 19 ^ *19 *$
Assign the third element in the list to a variable. Make up the variable name. cities = ["Atlanta", "Baltimore", "Chicago", "Denver", "Los Angeles", "Seattle"] third_on_list = cities[2] ^ *[a-zA-Z_][a-zA-Z0-9_]* = cities\[2\] *$
Code a list whose three elements are integers. Make up the name of the list and the integers. signups = [9, 14, 19] ^ *[a-zA-Z_][a-zA-Z0-9_]* = \[-?[0-9]+, -?[0-9]+, -?[0-9]+\] *$
Code a list whose two elements are strings. Make up the name of the list and the strings. cars = ["Tesla", "BMW"] ^ *[a-zA-Z_][a-zA-Z0-9_]* = \[•.+•, •.+•\] *$
In a single line of code and using the list to specify the element, display "Black". seas = ["North", "Red", "Dead", "Black", "Baltic", "Bali"] print(seas[3]) ^ *print\(seas\[3\]\) *$
  1. Complete line 2 to assign the last element of the list to the variable.
  2. Click the Run button   above your code. If you've coded correctly, Fri will display in the right-hand panel. (You can click Instructions at the top of the right-hand panel to see the correct code.)
3e2c2ebc4b
  1. Define a list that contains three elements.
  2. Display the list.
  3. Click the Run button   above your code. If you've coded correctly, the list will display in the right-hand panel. (You can click Instructions at the top of the right-hand panel to see the correct code.)
556f295c81