A Smarter Way to Learn Python / Chapter 2 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

Because of the quotation marks, Python identifies the greeting below as a _______ (1 word, lowercase)"Hello, World!"string^ *string *$
Because there are no quotation marks, Python identifies the set of characters below as a _______.country_of_originvariable^ *variable *$
Assign the string "Boo!" to the variable scare.scare = "Boo!"scare `= `"`Boo!`"
Assign the string "jay" to the variable bird.bird = "jay"bird = "jay"
Assign your first name to a variable. You choose the variable name.my_name = "Mark"^ *.* = •.+• *$
Assign a string to a variable. You choose the variable name and the string.gender = "female"^ *.* = •.*• *$
In the statement below, I assign a string to a variable. Using the variable, write the statement that displays the string on the screen. my_name = "Mark"print(my_name)^ *print\(my_name\) *$
Assign a string to a variable. You choose the variable name and the string. Using the variable, write a statement that displays the string on the screen.city = "London"
print(city)
^ *(.*) = •.*•\nprint\(\1\) *$
Revise this variable name as the Python governing body recommends.countryoforigincountry_of_origin^ *country_of_origin *$
Assign the string "Hi" to the variable greetinggreeting = "Hi"^ *greeting = •Hi• *$
  1. Click in the left-hand Trinket panel.
  2. On line 1, assign a string of your choice to a variable of your choice. On line 2, tell Python to display the string, using the variable.
  3. Click the Run button   above your code. If you've coded correctly, the string will display in the right-hand panel. (You can click Instructions at the top of the right-hand panel to see the correct code.)
9a611bed77
  1. Click in the left-hand Trinket panel.
  2. On line 1, assign your first name to a variable. On line 2, tell Python to display your first name using that variable.
  3. Click the Run button   above your code. If you've coded correctly, your name will display in the right-hand panel. (You can click Instructions at the top of the right-hand panel to see the correct code.)
82314bb296